Skip to content

Commit cad12f8

Browse files
committed
Fix: check configured is None after loop instead of separate list
1 parent 5da3048 commit cad12f8

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

  • opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation

opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ def _key_for(entry_point: EntryPoint):
6161

6262
def _load_distro() -> BaseDistro:
6363
distro_name = environ.get(OTEL_PYTHON_DISTRO, None)
64-
all_distros = list(entry_points(group="opentelemetry_distro"))
65-
if not all_distros:
66-
_logger.warning(
67-
"No distro found. Make sure 'opentelemetry-distro' is installed "
68-
"if you are using automatic instrumentation. "
69-
"See https://opentelemetry.io/docs/zero-code/python/ for details."
70-
)
71-
7264
for entry_point in entry_points(group="opentelemetry_distro"):
7365
try:
7466
# If no distro is specified, use first to come up.
@@ -168,15 +160,6 @@ def _load_instrumentors(distro):
168160
def _load_configurators():
169161
configurator_name = environ.get(OTEL_PYTHON_CONFIGURATOR, None)
170162
configured = None
171-
all_configurators = list(entry_points(group="opentelemetry_configurator"))
172-
if not all_configurators:
173-
_logger.warning(
174-
"No configurator found. Make sure 'opentelemetry-distro' is "
175-
"installed if you are using automatic instrumentation. "
176-
"See https://opentelemetry.io/docs/zero-code/python/ for details."
177-
)
178-
return
179-
180163
for entry_point in entry_points(group="opentelemetry_configurator"):
181164
if configured is not None:
182165
_logger.warning(
@@ -204,3 +187,10 @@ def _load_configurators():
204187
except Exception as exc: # pylint: disable=broad-except
205188
_logger.exception("Configuration of %s failed", entry_point.name)
206189
raise exc
190+
191+
if configured is None:
192+
_logger.warning(
193+
"No configurator found. Make sure 'opentelemetry-distro' is "
194+
"installed if you are using automatic instrumentation. "
195+
"See https://opentelemetry.io/docs/zero-code/python/ for details."
196+
)

0 commit comments

Comments
 (0)