From 1fd497ed0749a69f5bdabb560f0e66b236375148 Mon Sep 17 00:00:00 2001 From: John Karp Date: Mon, 29 Dec 2025 18:13:47 -0600 Subject: [PATCH] Reduce severity & verbosity of instrumentation ImportError (#1115) In auto-instrumentation context, it is expected that many of the supported target libraries will not be present. Hence, it does not make sense to flood logs with ImportErrors for this expected scenario. --- .../opentelemetry/instrumentation/auto_instrumentation/_load.py | 2 +- .../tests/auto_instrumentation/test_load.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index fab95bf843..a7da398467 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -145,7 +145,7 @@ def _load_instrumentors(distro): # environment regarding python version, libc, etc... In this case it's better # to skip the single instrumentation rather than failing to load everything # so treat differently ImportError than the rest of exceptions - _logger.exception( + _logger.warning( "Importing of %s failed, skipping it", entry_point.name ) continue diff --git a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py index c192c819b1..2e211aafde 100644 --- a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py +++ b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py @@ -376,7 +376,7 @@ def test_load_instrumentors_import_error_does_not_stop_everything( ] ) self.assertEqual(distro_mock.load_instrumentor.call_count, 2) - mock_logger.exception.assert_any_call( + mock_logger.warning.assert_any_call( "Importing of %s failed, skipping it", ep_mock1.name, )