Skip to content

Commit

Permalink
Store ScopeShim in context
Browse files Browse the repository at this point in the history
This uses the OpenTelemetry context management mechanism to store a
ScopeShim object in order to make active return the same object as the
one returned by start_active_span.

WIP: there is one failing test case, apparently the context does not get
cleared before running every test case. This seems related to the order
in which test cases are being run.
  • Loading branch information
ocelotl committed Aug 6, 2020
1 parent d457e65 commit 7994102
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ def close(self):
else:
self._span.unwrap().end()

detach(self._token)


class ScopeManagerShim(opentracing.ScopeManager):
"""Implements :class:`opentracing.ScopeManager` by setting and getting the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ def test_extract_empty_context_returns_invalid_context(self):
try:
carrier = {}

from ipdb import set_trace
set_trace()
ctx = self.shim.extract(opentracing.Format.HTTP_HEADERS, carrier)
self.assertEqual(ctx.unwrap(), trace.INVALID_SPAN_CONTEXT)
finally:
Expand Down

0 comments on commit 7994102

Please sign in to comment.