Skip to content

Commit faac707

Browse files
End server span after replying
1 parent 3b9d626 commit faac707

File tree

1 file changed

+4
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ async def __call__(self, scope, receive, send):
576576
if scope["type"] == "http":
577577
self.active_requests_counter.add(1, active_requests_count_attrs)
578578
try:
579-
with trace.use_span(span, end_on_exit=True) as current_span:
579+
with trace.use_span(span, end_on_exit=False) as current_span:
580580
if current_span.is_recording():
581581
for key, value in attributes.items():
582582
current_span.set_attribute(key, value)
@@ -703,5 +703,8 @@ async def otel_send(message):
703703
pass
704704

705705
await send(message)
706+
if message["type"] == "http.response.body":
707+
if not message.get("more_body", False):
708+
server_span.end()
706709

707710
return otel_send

0 commit comments

Comments
 (0)