Skip to content

Commit fc2ef84

Browse files
authored
Disable warning messages from OTel auto instrumentation (#449)
*Description of changes:* When setting `OTEL_PYTHON_CONFIGURATOR=aws_configurator`, users see a verbose warning message: `Configuration of configurator not loaded because aws_configurator is set by OTEL_PYTHON_CONFIGURATOR` These warnings appear when multiple OpenTelemetry configurators are installed (e.g., default upstream configurators alongside the AWS configurator). While the behavior is correct, the warnings create noise in application logs. Disabling this log message from showing up by default. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 339e83c commit fc2ef84

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_distro.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import importlib
44
import os
55
import sys
6-
from logging import Logger, getLogger
6+
from logging import ERROR, Logger, getLogger
77

88
from amazon.opentelemetry.distro._utils import get_aws_region, is_agent_observability_enabled
99
from amazon.opentelemetry.distro.aws_opentelemetry_configurator import (
@@ -22,12 +22,16 @@
2222
from opentelemetry import propagate
2323
from opentelemetry.distro import OpenTelemetryDistro
2424
from opentelemetry.environment_variables import OTEL_PROPAGATORS, OTEL_PYTHON_ID_GENERATOR
25+
from opentelemetry.instrumentation.auto_instrumentation import _load
26+
from opentelemetry.instrumentation.logging.environment_variables import OTEL_PYTHON_LOG_LEVEL
2527
from opentelemetry.sdk.environment_variables import (
2628
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION,
2729
OTEL_EXPORTER_OTLP_PROTOCOL,
2830
)
2931

3032
_logger: Logger = getLogger(__name__)
33+
# Suppress configurator warnings from OpenTelemetry auto-instrumentation
34+
_load._logger.setLevel(os.environ.get(OTEL_PYTHON_LOG_LEVEL, ERROR))
3135

3236

3337
class AwsOpenTelemetryDistro(OpenTelemetryDistro):

0 commit comments

Comments
 (0)