Skip to content

Commit

Permalink
Calling detach at the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Aug 5, 2020
1 parent 39316e4 commit ca29298
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
from deprecated import deprecated

from opentelemetry import propagators
from opentelemetry.context import Context, attach, get_value, set_value
from opentelemetry.context import Context, attach, detach, get_value, set_value
from opentelemetry.correlationcontext import get_correlation, set_correlation
from opentelemetry.ext.opentracing_shim import util
from opentelemetry.ext.opentracing_shim.version import __version__
Expand Down Expand Up @@ -327,7 +327,7 @@ class ScopeShim(opentracing.Scope):
def __init__(self, manager, span, span_cm=None):
super().__init__(manager, span)
self._span_cm = span_cm
attach(set_value("scope_shim", self))
self._token = attach(set_value("scope_shim", self))

# TODO: Change type of `manager` argument to `opentracing.ScopeManager`? We
# need to get rid of `manager.tracer` for this.
Expand Down Expand Up @@ -383,6 +383,8 @@ def close(self):
*finish_on_close* when activating the span.
"""

detach(self._token)

if self._span_cm is not None:
# We don't have error information to pass to `__exit__()` so we
# pass `None` in all arguments. If the OpenTelemetry tracer
Expand Down

0 comments on commit ca29298

Please sign in to comment.