Skip to content

Commit

Permalink
fix opentelemetry detach
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis committed Dec 11, 2024
1 parent 825c22a commit 00ecf62
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/service-library/src/servicelib/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ def get_context() -> TracingContext:

@contextmanager
def use_tracing_context(context: TracingContext):
token: object | None = None
if context is not None:
otcontext.attach(context)
token = otcontext.attach(context)
try:
yield
finally:
if context is not None:
otcontext.detach(context)
if token is not None:
otcontext.detach(token)


def setup_log_tracing(tracing_settings: TracingSettings):
Expand Down

0 comments on commit 00ecf62

Please sign in to comment.