From 1b1daa7795d604146256eab2455123a3dec2561f Mon Sep 17 00:00:00 2001 From: Sorin Munteanu Date: Thu, 23 Feb 2023 14:54:34 -0500 Subject: [PATCH] refactor propagators' initialization to accommodate Nuitka compilation to C++ code --- .../src/opentelemetry/propagate/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/opentelemetry-api/src/opentelemetry/propagate/__init__.py b/opentelemetry-api/src/opentelemetry/propagate/__init__.py index a39d8a44d1f..ded55e46970 100644 --- a/opentelemetry-api/src/opentelemetry/propagate/__init__.py +++ b/opentelemetry-api/src/opentelemetry/propagate/__init__.py @@ -132,11 +132,12 @@ def inject( for propagator in environ_propagators.split(","): propagator = propagator.strip() try: - propagators.append( # type: ignore - next( # type: ignore - iter_entry_points("opentelemetry_propagator", propagator) - ).load()() - ) + for entry in iter_entry_points("opentelemetry_propagator"): + if entry.name==propagator: + propagators.append( # type: ignore + entry.load()() + ) + break except Exception: # pylint: disable=broad-except logger.exception( "Failed to load configured propagator `%s`", propagator