From bf8919a197679936702bce9c79a0cf9e4bb9a9d2 Mon Sep 17 00:00:00 2001 From: siminn-arnorgj Date: Thu, 29 Jun 2023 17:28:51 +0000 Subject: [PATCH] End span on exception or other premature exits --- .../src/opentelemetry/instrumentation/asgi/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index 711103a96b..9161f580c7 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -630,6 +630,8 @@ async def __call__(self, scope, receive, send): ) if token: context.detach(token) + if span.is_recording(): + span.end() # pylint: enable=too-many-branches