Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor code to accomodate Nuitka compilation to C++ code #3154

14 changes: 7 additions & 7 deletions opentelemetry-api/src/opentelemetry/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ def wrapper( # type: ignore[misc]
) # type: str
try:

_RUNTIME_CONTEXT = next( # type: ignore
iter( # type: ignore
entry_points( # type: ignore
group="opentelemetry_context",
name=configured_context,
)
for entry_point in entry_points(group="opentelemetry_context"):
if entry_point.name==configured_context:
_RUNTIME_CONTEXT = entry_point.load()()
break
if _RUNTIME_CONTEXT is None:
logger.exception(
"Failed to load context (no such entry point): %s", configured_context
)
).load()()

except Exception: # pylint: disable=broad-except
logger.exception(
Expand Down
15 changes: 5 additions & 10 deletions opentelemetry-api/src/opentelemetry/propagate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,12 @@ def inject(
propagator = propagator.strip()

try:

propagators.append( # type: ignore
next( # type: ignore
iter( # type: ignore
entry_points( # type: ignore
group="opentelemetry_propagator",
name=propagator,
)
for entry in entry_points(group="opentelemetry_propagator"):
if entry.name==propagator:
propagators.append( # type: ignore
entry.load()()
)
).load()()
)
break

except Exception: # pylint: disable=broad-except
logger.exception(
Expand Down