Skip to content

Commit

Permalink
Fix Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oxeye-nikolay committed Sep 22, 2021
1 parent 76368f2 commit 7339ecb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def wrapper(wrapped, instance, args, kwargs):

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

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

def instrumentation_dependencies(self) -> Collection[str]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def test_instrument_api(self) -> None:
self.assertTrue(
isinstance(BlockingConnection.channel, BoundFunctionWrapper)
)
assert hasattr(
instrumentation, "__opentelemetry_tracer"
), "Tracer not stored for the object!"
instrumentation.uninstrument(channel=self.channel)
self.assertFalse(
isinstance(BlockingConnection.channel, BoundFunctionWrapper)
Expand All @@ -52,8 +55,8 @@ def test_instrument(
):
PikaInstrumentor.instrument_channel(channel=self.channel)
assert hasattr(
self.channel, "__opentelemetry_tracer"
), "Tracer not set for the channel!"
self.channel, "_is_instrumented_by_opentelemetry"
), "channel is not marked as instrumented!"
instrument_consumers.assert_called_once()
instrument_channel_functions.assert_called_once()

Expand Down

0 comments on commit 7339ecb

Please sign in to comment.