Skip to content

Commit 7339ecb

Browse files
committed
Fix Tests
1 parent 76368f2 commit 7339ecb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ def wrapper(wrapped, instance, args, kwargs):
122122

123123
def _instrument(self, **kwargs: Dict[str, Any]) -> None:
124124
tracer_provider: TracerProvider = kwargs.get("tracer_provider", None)
125-
channel.__setattr__("__opentelemetry_tracer", tracer)
125+
self.__setattr__("__opentelemetry_tracer", tracer_provider)
126126
self._decorate_channel_function(tracer_provider)
127127

128128
def _uninstrument(self, **kwargs: Dict[str, Any]) -> None:
129-
if hasattr(channel, "__opentelemetry_tracer"):
130-
delattr(channel, "__opentelemetry_tracer")
129+
if hasattr(self, "__opentelemetry_tracer"):
130+
delattr(self, "__opentelemetry_tracer")
131131
unwrap(BlockingConnection, "channel")
132132

133133
def instrumentation_dependencies(self) -> Collection[str]:

instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def test_instrument_api(self) -> None:
3434
self.assertTrue(
3535
isinstance(BlockingConnection.channel, BoundFunctionWrapper)
3636
)
37+
assert hasattr(
38+
instrumentation, "__opentelemetry_tracer"
39+
), "Tracer not stored for the object!"
3740
instrumentation.uninstrument(channel=self.channel)
3841
self.assertFalse(
3942
isinstance(BlockingConnection.channel, BoundFunctionWrapper)
@@ -52,8 +55,8 @@ def test_instrument(
5255
):
5356
PikaInstrumentor.instrument_channel(channel=self.channel)
5457
assert hasattr(
55-
self.channel, "__opentelemetry_tracer"
56-
), "Tracer not set for the channel!"
58+
self.channel, "_is_instrumented_by_opentelemetry"
59+
), "channel is not marked as instrumented!"
5760
instrument_consumers.assert_called_once()
5861
instrument_channel_functions.assert_called_once()
5962

0 commit comments

Comments
 (0)