Skip to content

Commit 6201424

Browse files
committed
wip tests
1 parent f9ee608 commit 6201424

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def wrapper(wrapped, instance, args, kwargs):
213213
)
214214

215215
def _instrument(self, **kwargs: Dict[str, Any]) -> None:
216+
print("in instrument 1")
216217
tracer_provider: TracerProvider = kwargs.get("tracer_provider", None)
217218
publish_hook: utils.HookT = kwargs.get(
218219
"publish_hook", utils.dummy_callback
@@ -228,6 +229,8 @@ def _instrument(self, **kwargs: Dict[str, Any]) -> None:
228229
consume_hook=consume_hook,
229230
)
230231

232+
233+
print("in instrument 2")
231234
self._decorate_queue_consumer_generator(
232235
tracer_provider, consume_hook=consume_hook
233236
)

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from unittest import TestCase, mock
1515

1616
from pika.adapters import BlockingConnection
17+
from pika.adapters.blocking_connection import _QueueConsumerGeneratorInfo
1718
from pika.channel import Channel
1819
from wrapt import BoundFunctionWrapper
1920

@@ -40,6 +41,9 @@ def test_instrument_api(self) -> None:
4041
self.assertTrue(
4142
isinstance(BlockingConnection.channel, BoundFunctionWrapper)
4243
)
44+
self.assertTrue(
45+
isinstance(_QueueConsumerGeneratorInfo.__init__, BoundFunctionWrapper)
46+
)
4347
assert hasattr(
4448
instrumentation, "__opentelemetry_tracer_provider"
4549
), "Tracer not stored for the object!"
@@ -57,15 +61,11 @@ def test_instrument_api(self) -> None:
5761
@mock.patch(
5862
"opentelemetry.instrumentation.pika.PikaInstrumentor._instrument_blocking_channel_consumers"
5963
)
60-
@mock.patch(
61-
"opentelemetry.instrumentation.pika.PikaInstrumentor._decorate_queue_consumer_generator"
62-
)
63-
def test_instrument(
64+
def test_instrument_channel(
6465
self,
6566
instrument_blocking_channel_consumers: mock.MagicMock,
6667
instrument_basic_consume: mock.MagicMock,
6768
instrument_channel_functions: mock.MagicMock,
68-
instrument_queue_consumer_generator: mock.MagicMock,
6969
):
7070
PikaInstrumentor.instrument_channel(channel=self.channel)
7171
assert hasattr(
@@ -74,7 +74,6 @@ def test_instrument(
7474
instrument_blocking_channel_consumers.assert_called_once()
7575
instrument_basic_consume.assert_called_once()
7676
instrument_channel_functions.assert_called_once()
77-
instrument_queue_consumer_generator.assert_called_once()
7877

7978
@mock.patch("opentelemetry.instrumentation.pika.utils._decorate_callback")
8079
def test_instrument_consumers(

0 commit comments

Comments
 (0)