Skip to content

Commit

Permalink
End server span after replying
Browse files Browse the repository at this point in the history
  • Loading branch information
siminn-arnorgj committed Nov 8, 2023
1 parent 3b9d626 commit faac707
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ async def __call__(self, scope, receive, send):
if scope["type"] == "http":
self.active_requests_counter.add(1, active_requests_count_attrs)
try:
with trace.use_span(span, end_on_exit=True) as current_span:
with trace.use_span(span, end_on_exit=False) as current_span:
if current_span.is_recording():
for key, value in attributes.items():
current_span.set_attribute(key, value)
Expand Down Expand Up @@ -703,5 +703,8 @@ async def otel_send(message):
pass

await send(message)
if message["type"] == "http.response.body":
if not message.get("more_body", False):
server_span.end()

return otel_send

0 comments on commit faac707

Please sign in to comment.