diff --git a/instana/instrumentation/pika.py b/instana/instrumentation/pika.py index e26bf2007..550d93887 100644 --- a/instana/instrumentation/pika.py +++ b/instana/instrumentation/pika.py @@ -76,8 +76,11 @@ def _bind_args(exchange, routing_key, body, properties=None, *args, **kwargs): def basic_get_with_instana(wrapped, instance, args, kwargs): - def _bind_args(queue, callback, *args, **kwargs): - return (queue, callback, args, kwargs) + def _bind_args(*args, **kwargs): + args = list(args) + queue = kwargs.pop('queue', None) or args.pop(0) + callback = kwargs.pop('callback', None) or kwargs.pop('on_message_callback', None) or args.pop(0) + return (queue, callback, tuple(args), kwargs) queue, callback, args, kwargs = _bind_args(*args, **kwargs) @@ -102,13 +105,12 @@ def _cb_wrapper(channel, method, properties, body): args = (queue, _cb_wrapper) + args return wrapped(*args, **kwargs) - @wrapt.patch_function_wrapper('pika.adapters.blocking_connection', 'BlockingChannel.basic_consume') def basic_consume_with_instana(wrapped, instance, args, kwargs): - def _bind_args(queue, on_consume_callback, *args, **kwargs): - return (queue, on_consume_callback, args, kwargs) + def _bind_args(queue, on_message_callback, *args, **kwargs): + return (queue, on_message_callback, args, kwargs) - queue, on_consume_callback, args, kwargs = _bind_args(*args, **kwargs) + queue, on_message_callback, args, kwargs = _bind_args(*args, **kwargs) def _cb_wrapper(channel, method, properties, body): parent_span = tracer.extract(opentracing.Format.HTTP_HEADERS, properties.headers, @@ -123,7 +125,7 @@ def _cb_wrapper(channel, method, properties, body): logger.debug("basic_consume_with_instana: ", exc_info=True) try: - on_consume_callback(channel, method, properties, body) + on_message_callback(channel, method, properties, body) except Exception as e: scope.span.log_exception(e) raise diff --git a/instana/version.py b/instana/version.py index 2c1ea5535..bb9b16d5d 100644 --- a/instana/version.py +++ b/instana/version.py @@ -3,4 +3,4 @@ # Module version file. Used by setup.py and snapshot reporting. -VERSION = '1.36.0' +VERSION = '1.36.1' diff --git a/tests/clients/test_pika.py b/tests/clients/test_pika.py index bfa9740c8..4a06d2ebb 100644 --- a/tests/clients/test_pika.py +++ b/tests/clients/test_pika.py @@ -246,7 +246,7 @@ def test_basic_consume_with_trace_context(self, _unused): cb = mock.Mock() - self.obj.basic_consume("test.queue", cb, consumer_tag="test") + self.obj.basic_consume(queue="test.queue", on_message_callback=cb, consumer_tag="test") self.obj._on_deliver(method_frame, header_frame, body) spans = self.recorder.queued_spans()