Skip to content

Commit 805c72c

Browse files
authored
rename type to asgi.event.type in ASGI instrumentation (#2300)
1 parent 955b483 commit 805c72c

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Breaking changes
11+
12+
- Rename `type` attribute to `asgi.event.type` in `opentelemetry-instrumentation-asgi`
13+
([#2300](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2300))
14+
1015
## Version 1.24.0/0.45b0 (2024-03-28)
1116

17+
### Added
18+
1219
- `opentelemetry-instrumentation-psycopg` Async Instrumentation for psycopg 3.x
1320
([#2146](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2146))
1421

@@ -30,9 +37,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3037
- AwsLambdaInstrumentor sets `cloud.account.id` span attribute
3138
([#2367](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2367))
3239

40+
3341
## Version 1.23.0/0.44b0 (2024-02-23)
3442

35-
- Drop uspport for 3.7
43+
- Drop support for 3.7
3644
([#2151](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2151))
3745
- `opentelemetry-resource-detector-azure` Added 10s timeout to VM Resource Detector
3846
([#2119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2119))

instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,9 @@ async def otel_receive():
672672
if receive_span.is_recording():
673673
if message["type"] == "websocket.receive":
674674
set_status_code(receive_span, 200)
675-
receive_span.set_attribute("type", message["type"])
675+
receive_span.set_attribute(
676+
"asgi.event.type", message["type"]
677+
)
676678
return message
677679

678680
return otel_receive
@@ -703,7 +705,7 @@ async def otel_send(message: dict[str, Any]):
703705
elif message["type"] == "websocket.send":
704706
set_status_code(server_span, 200)
705707
set_status_code(send_span, 200)
706-
send_span.set_attribute("type", message["type"])
708+
send_span.set_attribute("asgi.event.type", message["type"])
707709
if (
708710
server_span.is_recording()
709711
and server_span.kind == trace.SpanKind.SERVER

instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -268,20 +268,20 @@ def validate_outputs(self, outputs, error=None, modifiers=None):
268268
{
269269
"name": "GET / http receive",
270270
"kind": trace_api.SpanKind.INTERNAL,
271-
"attributes": {"type": "http.request"},
271+
"attributes": {"asgi.event.type": "http.request"},
272272
},
273273
{
274274
"name": "GET / http send",
275275
"kind": trace_api.SpanKind.INTERNAL,
276276
"attributes": {
277277
SpanAttributes.HTTP_STATUS_CODE: 200,
278-
"type": "http.response.start",
278+
"asgi.event.type": "http.response.start",
279279
},
280280
},
281281
{
282282
"name": "GET / http send",
283283
"kind": trace_api.SpanKind.INTERNAL,
284-
"attributes": {"type": "http.response.body"},
284+
"attributes": {"asgi.event.type": "http.response.body"},
285285
},
286286
{
287287
"name": "GET /",
@@ -358,7 +358,7 @@ def add_more_body_spans(expected: list):
358358
more_body_span = {
359359
"name": "GET / http send",
360360
"kind": trace_api.SpanKind.INTERNAL,
361-
"attributes": {"type": "http.response.body"},
361+
"attributes": {"asgi.event.type": "http.response.body"},
362362
}
363363
extra_spans = [more_body_span] * 3
364364
expected[2:2] = extra_spans
@@ -396,12 +396,12 @@ def add_body_and_trailer_span(expected: list):
396396
body_span = {
397397
"name": "GET / http send",
398398
"kind": trace_api.SpanKind.INTERNAL,
399-
"attributes": {"type": "http.response.body"},
399+
"attributes": {"asgi.event.type": "http.response.body"},
400400
}
401401
trailer_span = {
402402
"name": "GET / http send",
403403
"kind": trace_api.SpanKind.INTERNAL,
404-
"attributes": {"type": "http.response.trailers"},
404+
"attributes": {"asgi.event.type": "http.response.trailers"},
405405
}
406406
expected[2:2] = [body_span]
407407
expected[4:4] = [trailer_span] * 2
@@ -582,33 +582,33 @@ def test_websocket(self):
582582
{
583583
"name": "/ websocket receive",
584584
"kind": trace_api.SpanKind.INTERNAL,
585-
"attributes": {"type": "websocket.connect"},
585+
"attributes": {"asgi.event.type": "websocket.connect"},
586586
},
587587
{
588588
"name": "/ websocket send",
589589
"kind": trace_api.SpanKind.INTERNAL,
590-
"attributes": {"type": "websocket.accept"},
590+
"attributes": {"asgi.event.type": "websocket.accept"},
591591
},
592592
{
593593
"name": "/ websocket receive",
594594
"kind": trace_api.SpanKind.INTERNAL,
595595
"attributes": {
596-
"type": "websocket.receive",
596+
"asgi.event.type": "websocket.receive",
597597
SpanAttributes.HTTP_STATUS_CODE: 200,
598598
},
599599
},
600600
{
601601
"name": "/ websocket send",
602602
"kind": trace_api.SpanKind.INTERNAL,
603603
"attributes": {
604-
"type": "websocket.send",
604+
"asgi.event.type": "websocket.send",
605605
SpanAttributes.HTTP_STATUS_CODE: 200,
606606
},
607607
},
608608
{
609609
"name": "/ websocket receive",
610610
"kind": trace_api.SpanKind.INTERNAL,
611-
"attributes": {"type": "websocket.disconnect"},
611+
"attributes": {"asgi.event.type": "websocket.disconnect"},
612612
},
613613
{
614614
"name": "/",

0 commit comments

Comments
 (0)