Skip to content

Commit

Permalink
removing span member on object proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
galbash committed Apr 8, 2024
1 parent 578197b commit 497190e
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def __init__(
consume_hook: HookT = dummy_callback,
):
super().__init__(wrapped)
self._self_active_span: Optional[Span] = None
self._self_active_token = None
self._self_tracer = tracer
self._self_consume_hook = consume_hook
Expand All @@ -221,11 +220,12 @@ def popleft(self, *args, **kwargs):
context.detach(self._self_active_token)
except Exception as inst_exception: # pylint: disable=W0703
_LOG.exception(inst_exception)

evt = self.__wrapped__.popleft(*args, **kwargs)

try:
# If a new message was received, create a span and set as active
# If a new message was received, create a span and set as active context
if type(evt) is _ConsumerDeliveryEvt:
# start span
method = evt.method
properties = evt.properties
if not properties:
Expand All @@ -238,7 +238,7 @@ def popleft(self, *args, **kwargs):
if not ctx:
ctx = context.get_current()
message_ctx_token = context.attach(ctx)
self._self_active_span = _get_span(
span = _get_span(
self._self_tracer,
None,
properties,
Expand All @@ -251,12 +251,10 @@ def popleft(self, *args, **kwargs):
)
context.detach(message_ctx_token)
self._self_active_token = context.attach(
trace.set_span_in_context(self._self_active_span)
trace.set_span_in_context(span)
)
try:
self._self_consume_hook(
self._self_active_span, evt.body, properties
)
self._self_consume_hook(span, evt.body, properties)
except Exception as hook_exception: # pylint: disable=W0703
_LOG.exception(hook_exception)

Expand All @@ -265,7 +263,7 @@ def popleft(self, *args, **kwargs):
# arrives. we still set this span's context as the active context
# so user code that handles this message will co child-spans of
# this one.
self._self_active_span.end()
span.end()
except Exception as inst_exception: # pylint: disable=W0703
_LOG.exception(inst_exception)

Expand Down

0 comments on commit 497190e

Please sign in to comment.