Skip to content

Commit 172c405

Browse files
committed
removing span member on object proxy
1 parent 578197b commit 172c405

File tree

1 file changed

+6
-8
lines changed
  • instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika

1 file changed

+6
-8
lines changed

instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def __init__(
208208
consume_hook: HookT = dummy_callback,
209209
):
210210
super().__init__(wrapped)
211-
self._self_active_span: Optional[Span] = None
212211
self._self_active_token = None
213212
self._self_tracer = tracer
214213
self._self_consume_hook = consume_hook
@@ -221,11 +220,12 @@ def popleft(self, *args, **kwargs):
221220
context.detach(self._self_active_token)
222221
except Exception as inst_exception: # pylint: disable=W0703
223222
_LOG.exception(inst_exception)
223+
224224
evt = self.__wrapped__.popleft(*args, **kwargs)
225+
225226
try:
226-
# If a new message was received, create a span and set as active
227+
# If a new message was received, create a span and set as active context
227228
if type(evt) is _ConsumerDeliveryEvt:
228-
# start span
229229
method = evt.method
230230
properties = evt.properties
231231
if not properties:
@@ -238,7 +238,7 @@ def popleft(self, *args, **kwargs):
238238
if not ctx:
239239
ctx = context.get_current()
240240
message_ctx_token = context.attach(ctx)
241-
self._self_active_span = _get_span(
241+
span = _get_span(
242242
self._self_tracer,
243243
None,
244244
properties,
@@ -251,12 +251,10 @@ def popleft(self, *args, **kwargs):
251251
)
252252
context.detach(message_ctx_token)
253253
self._self_active_token = context.attach(
254-
trace.set_span_in_context(self._self_active_span)
254+
trace.set_span_in_context(span)
255255
)
256256
try:
257-
self._self_consume_hook(
258-
self._self_active_span, evt.body, properties
259-
)
257+
self._self_consume_hook(span, evt.body, properties)
260258
except Exception as hook_exception: # pylint: disable=W0703
261259
_LOG.exception(hook_exception)
262260

0 commit comments

Comments
 (0)