Change logic for finding instrumentation finder
@@ -341,11 +341,13 @@ def _reload_instrumentation_loader(
module_name = config.configuration.module_name
module = importlib.import_module(module_name)
tracer.current_thread_identifier = threading.current_thread().ident
- first_finder = sys.meta_path[0]
- assert isinstance(first_finder, InstrumentationFinder)
- finder: InstrumentationFinder = first_finder
- # pylint:disable=no-member
- finder.update_instrumentation_metrics(
+ first_finder: InstrumentationFinder | None = None
+ for finder in sys.meta_path:
+ if isinstance(finder, InstrumentationFinder):
+ first_finder = finder
+ break
+ assert first_finder is not None
+ first_finder.update_instrumentation_metrics(
tracer=tracer,
coverage_metrics=coverage_metrics,
dynamic_constant_provider=dynamic_constant_provider,
