diff --git a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py index d01b59ee54..a4419c90e0 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py +++ b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py @@ -1,5 +1,5 @@ -from typing import Any, Callable, List, Optional from logging import getLogger +from typing import Any, Callable, List, Optional from pika.channel import Channel from pika.spec import Basic, BasicProperties @@ -68,8 +68,8 @@ def decorated_callback( with trace.use_span(span, end_on_exit=True): try: consume_hook(span, body, properties) - except Exception as e: # noqa: W0703 (Ignore lint error: "Catching too general exception") - _LOG.exception(e) + except Exception as hook_exception: # noqa: W0703 (Ignore lint error: "Catching too general exception") + _LOG.exception(hook_exception) retval = callback(channel, method, properties, body) return retval @@ -112,8 +112,8 @@ def decorated_function( propagate.inject(properties.headers) try: publish_hook(span, body, properties) - except Exception as e: # noqa: W0703 (Ignore lint error: "Catching too general exception") - _LOG.exception(e) + except Exception as hook_exception: # noqa: W0703 (Ignore lint error: "Catching too general exception") + _LOG.exception(hook_exception) retval = original_function( exchange, routing_key, body, properties, mandatory ) diff --git a/instrumentation/opentelemetry-instrumentation-pika/tests/test_utils.py b/instrumentation/opentelemetry-instrumentation-pika/tests/test_utils.py index cebc0ef684..f22bbc71ad 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/tests/test_utils.py +++ b/instrumentation/opentelemetry-instrumentation-pika/tests/test_utils.py @@ -248,7 +248,9 @@ def test_decorate_callback_with_hook( use_span.assert_called_once_with( get_span.return_value, end_on_exit=True ) - consume_hook.assert_called_once_with(get_span.return_value, mock_body, properties) + consume_hook.assert_called_once_with( + get_span.return_value, mock_body, properties + ) callback.assert_called_once_with( channel, method, properties, mock_body ) @@ -371,5 +373,7 @@ def test_decorate_basic_publish_with_hook( callback.assert_called_once_with( channel, method, mock_body, mock_properties, False ) - publish_hook.assert_called_once_with(get_span.return_value, mock_body, mock_properties) + publish_hook.assert_called_once_with( + get_span.return_value, mock_body, mock_properties + ) self.assertEqual(retval, callback.return_value)