Skip to content

Commit 9c32d80

Browse files
fix: server span logic should always be executed if recording
1 parent 9daafa7 commit 9c32d80

File tree

1 file changed

+19
-19
lines changed
  • instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi

1 file changed

+19
-19
lines changed

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

+19-19
Original file line numberDiff line numberDiff line change
@@ -868,25 +868,25 @@ async def otel_send(message: dict[str, Any]):
868868
self._sem_conv_opt_in_mode,
869869
)
870870

871-
if (
872-
server_span.is_recording()
873-
and server_span.kind == trace.SpanKind.SERVER
874-
and "headers" in message
875-
):
876-
custom_response_attributes = (
877-
collect_custom_headers_attributes(
878-
message,
879-
self.http_capture_headers_sanitize_fields,
880-
self.http_capture_headers_server_response,
881-
normalise_response_header_name,
882-
)
883-
if self.http_capture_headers_server_response
884-
else {}
885-
)
886-
if len(custom_response_attributes) > 0:
887-
server_span.set_attributes(
888-
custom_response_attributes
889-
)
871+
if (
872+
server_span.is_recording()
873+
and server_span.kind == trace.SpanKind.SERVER
874+
and "headers" in message
875+
):
876+
custom_response_attributes = (
877+
collect_custom_headers_attributes(
878+
message,
879+
self.http_capture_headers_sanitize_fields,
880+
self.http_capture_headers_server_response,
881+
normalise_response_header_name,
882+
)
883+
if self.http_capture_headers_server_response
884+
else {}
885+
)
886+
if len(custom_response_attributes) > 0:
887+
server_span.set_attributes(
888+
custom_response_attributes
889+
)
890890

891891
if status_code:
892892
set_status_code(

0 commit comments

Comments
 (0)