From bc01feb03867a78be05d94c1be656bac9ab9053b Mon Sep 17 00:00:00 2001 From: Ran Nozik Date: Mon, 20 Dec 2021 19:48:50 +0200 Subject: [PATCH] add callback attr name test --- .../tests/test_pika_instrumentation.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py b/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py index 3c176f21d0..a09e3b1203 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py @@ -18,6 +18,7 @@ from wrapt import BoundFunctionWrapper from opentelemetry.instrumentation.pika import PikaInstrumentor +from opentelemetry.instrumentation.pika.pika_instrumentor import _consumer_callback_attribute_name from opentelemetry.instrumentation.pika.utils import dummy_callback from opentelemetry.trace import Tracer @@ -113,3 +114,9 @@ def test_uninstrument_channel_functions(self) -> None: self.channel.basic_publish._original_function = original_function PikaInstrumentor._uninstrument_channel_functions(self.channel) self.assertEqual(self.channel.basic_publish, original_function) + + def test_consumer_callback_attribute_name(self) -> None: + with mock.patch("pika.__version__", "1.0.0"): + assert _consumer_callback_attribute_name() == "on_message_callback" + with mock.patch("pika.__version__", "0.12.0"): + assert _consumer_callback_attribute_name() == "consumer_cb"