Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename type to asgi.event.type in ASGI instrumentation #2300

Merged
merged 9 commits into from
Apr 4, 2024
Merged
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Breaking changes

- Rename `type` attribute to `asgi.event.type` in `opentelemetry-instrumentation-asgi`
([#2300](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2300))

### Added

- `opentelemetry-instrumentation-psycopg` Async Instrumentation for psycopg 3.x
([#2146](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2146))

Expand All @@ -28,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- AwsLambdaInstrumentor sets `cloud.account.id` span attribute
([#2367](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2367))



## Version 1.23.0/0.44b0 (2024-02-23)

- Drop uspport for 3.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ async def otel_receive():
if receive_span.is_recording():
if message["type"] == "websocket.receive":
set_status_code(receive_span, 200)
receive_span.set_attribute("type", message["type"])
receive_span.set_attribute("asgi.event.type", message["type"])
return message

return otel_receive
Expand Down Expand Up @@ -703,7 +703,7 @@ async def otel_send(message: dict[str, Any]):
elif message["type"] == "websocket.send":
set_status_code(server_span, 200)
set_status_code(send_span, 200)
send_span.set_attribute("type", message["type"])
send_span.set_attribute("asgi.event.type", message["type"])
if (
server_span.is_recording()
and server_span.kind == trace.SpanKind.SERVER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,8 @@ def test_http_custom_request_headers_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
expected = {
"http.request.header.custom_test_header_1": (
"test-header-value-1",
),
"http.request.header.custom_test_header_2": (
"test-header-value-2",
),
"http.request.header.custom_test_header_1": ("test-header-value-1",),
"http.request.header.custom_test_header_2": ("test-header-value-2",),
"http.request.header.regex_test_header_1": ("Regex Test Value 1",),
"http.request.header.regex_test_header_2": (
"RegexTestValue2,RegexTestValue3",
Expand Down Expand Up @@ -169,14 +165,10 @@ def test_http_custom_request_headers_not_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
expected = {
"http.request.header.custom_test_header_1": (
"test-header-value-1",
),
"http.request.header.custom_test_header_1": ("test-header-value-1",),
}
not_expected = {
"http.request.header.custom_test_header_2": (
"test-header-value-2",
),
"http.request.header.custom_test_header_2": ("test-header-value-2",),
}
for span in span_list:
if span.kind == SpanKind.SERVER:
Expand All @@ -195,12 +187,8 @@ def test_http_custom_response_headers_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
expected = {
"http.response.header.custom_test_header_1": (
"test-header-value-1",
),
"http.response.header.custom_test_header_2": (
"test-header-value-2",
),
"http.response.header.custom_test_header_1": ("test-header-value-1",),
"http.response.header.custom_test_header_2": ("test-header-value-2",),
"http.response.header.my_custom_regex_header_1": (
"my-custom-regex-value-1,my-custom-regex-value-2",
),
Expand Down Expand Up @@ -242,9 +230,7 @@ def test_http_custom_response_headers_not_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
not_expected = {
"http.response.header.custom_test_header_3": (
"test-header-value-3",
),
"http.response.header.custom_test_header_3": ("test-header-value-3",),
}
for span in span_list:
if span.kind == SpanKind.SERVER:
Expand Down Expand Up @@ -276,12 +262,8 @@ def test_websocket_custom_request_headers_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
expected = {
"http.request.header.custom_test_header_1": (
"test-header-value-1",
),
"http.request.header.custom_test_header_2": (
"test-header-value-2",
),
"http.request.header.custom_test_header_1": ("test-header-value-1",),
"http.request.header.custom_test_header_2": ("test-header-value-2",),
"http.request.header.regex_test_header_1": ("Regex Test Value 1",),
"http.request.header.regex_test_header_2": (
"RegexTestValue2,RegexTestValue3",
Expand Down Expand Up @@ -314,9 +296,7 @@ def test_websocket_custom_request_headers_not_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
not_expected = {
"http.request.header.custom_test_header_3": (
"test-header-value-3",
),
"http.request.header.custom_test_header_3": ("test-header-value-3",),
}
for span in span_list:
if span.kind == SpanKind.SERVER:
Expand Down Expand Up @@ -346,12 +326,8 @@ def test_websocket_custom_response_headers_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
expected = {
"http.response.header.custom_test_header_1": (
"test-header-value-1",
),
"http.response.header.custom_test_header_2": (
"test-header-value-2",
),
"http.response.header.custom_test_header_1": ("test-header-value-1",),
"http.response.header.custom_test_header_2": ("test-header-value-2",),
"http.response.header.my_custom_regex_header_1": (
"my-custom-regex-value-1,my-custom-regex-value-2",
),
Expand Down Expand Up @@ -387,9 +363,7 @@ def test_websocket_custom_response_headers_not_in_span_attributes(self):
self.get_all_output()
span_list = self.exporter.get_finished_spans()
not_expected = {
"http.response.header.custom_test_header_3": (
"test-header-value-3",
),
"http.response.header.custom_test_header_3": ("test-header-value-3",),
}
for span in span_list:
if span.kind == SpanKind.SERVER:
Expand All @@ -414,27 +388,15 @@ def setUp(self):
super().setUp()

def tearDown(self):
os.environ.pop(
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS, None
)
os.environ.pop(
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST, None
)
os.environ.pop(
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE, None
)
os.environ.pop(OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS, None)
os.environ.pop(OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST, None)
os.environ.pop(OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE, None)
super().tearDown()


class TestCustomHeadersConstructor(TestCustomHeaders):
constructor_params = {
"http_capture_headers_sanitize_fields": SANITIZE_FIELDS_TEST_VALUE.split(
","
),
"http_capture_headers_server_request": SERVER_REQUEST_TEST_VALUE.split(
","
),
"http_capture_headers_server_response": SERVER_RESPONSE_TEST_VALUE.split(
","
),
"http_capture_headers_sanitize_fields": SANITIZE_FIELDS_TEST_VALUE.split(","),
"http_capture_headers_server_request": SERVER_REQUEST_TEST_VALUE.split(","),
"http_capture_headers_server_response": SERVER_RESPONSE_TEST_VALUE.split(","),
}
Loading
Loading