Skip to content

Commit

Permalink
do not log warning for OTEL_PYTHON_CONTEXT
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Nov 14, 2024
1 parent eb32554 commit f803a3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
9 changes: 2 additions & 7 deletions ddtrace/settings/_otel_remapper.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import os
import sys
import typing

from ..constants import ENV_KEY
from ..constants import VERSION_KEY
from ..internal.logger import get_logger
from ..internal.telemetry import telemetry_writer


if sys.version_info >= (3, 8):
import typing
else:
import typing_extensions as typing # noqa: F401

log = get_logger(__name__)


Expand Down Expand Up @@ -147,7 +142,7 @@ def otel_remapping():

for otel_env, otel_value in user_envs.items():
if otel_env not in ENV_VAR_MAPPINGS:
if otel_env.startswith("OTEL_"):
if otel_env.startswith("OTEL_") and otel_env != "OTEL_PYTHON_CONTEXT":
log.warning("OpenTelemetry configuration %s is not supported by Datadog.", otel_env)
telemetry_writer.add_count_metric(
"tracer", "otel.env.unsupported", 1, (("config_opentelemetry", otel_env.lower()),)
Expand Down
23 changes: 12 additions & 11 deletions tests/opentelemetry/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"OTEL_SDK_DISABLED": "True",
"DD_TRACE_OTEL_ENABLED": "True",
},
err=b"Unsupported OTEL logs exporter value detected: warning. Only the 'none' value is supported.\n",
err=b"Setting OTEL_LOGS_EXPORTER to warning is not supported by ddtrace, this configuration will be ignored.\n",
)
def test_dd_otel_mixed_env_configuration():
from ddtrace import config
Expand Down Expand Up @@ -54,8 +54,8 @@ def test_dd_otel_mixed_env_configuration():
"OTEL_SDK_DISABLED": "False",
},
err=b"Following style not supported by ddtrace: jaegar.\n"
b"A trace exporter value 'otlp' is set, but not supported. Traces will be exported to Datadog.\n"
b"Unsupported OTEL logs exporter value detected: warning. Only the 'none' value is supported.\n",
b"Setting OTEL_TRACES_EXPORTER to otlp is not supported by ddtrace, "
b"this configuration will be ignored.\n",
)
def test_dd_otel_missing_dd_env_configuration():
from ddtrace import config
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_otel_log_level_configuration_debug():

@pytest.mark.subprocess(
env={"OTEL_LOG_LEVEL": "trace"},
err=b"ddtrace does not support otel log level 'trace'. ddtrace only supports enabling debug logs.\n",
err=b"Setting OTEL_LOG_LEVEL to trace is not supported by ddtrace, this configuration will be ignored.\n",
)
def test_otel_log_level_configuration_info():
from ddtrace import config
Expand All @@ -103,7 +103,7 @@ def test_otel_log_level_configuration_info():

@pytest.mark.subprocess(
env={"OTEL_LOG_LEVEL": "warning"},
err=b"ddtrace does not support otel log level 'warning'. ddtrace only supports enabling debug logs.\n",
err=b"Setting OTEL_LOG_LEVEL to warning is not supported by ddtrace, this configuration will be ignored.\n",
)
def test_otel_log_level_configuration_unsupported():
from ddtrace import config
Expand Down Expand Up @@ -162,7 +162,8 @@ def test_otel_traces_sampler_configuration_alwaysoff():
"OTEL_TRACES_SAMPLER": "traceidratio",
"OTEL_TRACES_SAMPLER_ARG": "0.5",
},
err=b"Trace sampler set from traceidratio to parentbased_traceidratio; only parent based sampling is supported.\n",
err=b"Trace sampler set from traceidratio to parentbased_traceidratio; only parent based sampling is supported.\n"
b"OpenTelemetry configuration OTEL_TRACES_SAMPLER_ARG is not supported by Datadog.\n",
)
def test_otel_traces_sampler_configuration_traceidratio():
from ddtrace import config
Expand All @@ -179,7 +180,7 @@ def test_otel_traces_exporter_configuration():

@pytest.mark.subprocess(
env={"OTEL_TRACES_EXPORTER": "true"},
err=b"A trace exporter value 'true' is set, but not supported. Traces will be exported to Datadog.\n",
err=b"Setting OTEL_TRACES_EXPORTER to true is not supported by ddtrace, this configuration will be ignored.\n",
)
def test_otel_traces_exporter_configuration_unsupported_exporter():
from ddtrace import config
Expand All @@ -196,7 +197,7 @@ def test_otel_metrics_exporter_configuration():

@pytest.mark.subprocess(
env={"OTEL_METRICS_EXPORTER": "true"},
err=b"Metrics exporter value is set to unrecognized value: true.\n",
err=b"Setting OTEL_METRICS_EXPORTER to true is not supported by ddtrace, this configuration will be ignored.\n",
)
def test_otel_metrics_exporter_configuration_unsupported_exporter():
from ddtrace import config
Expand All @@ -206,7 +207,7 @@ def test_otel_metrics_exporter_configuration_unsupported_exporter():

@pytest.mark.subprocess(
env={"otel_LOGS_EXPORTER": "console"},
err=b"Unsupported OTEL logs exporter value detected: console. Only the 'none' value is supported.\n",
err=b"Setting OTEL_LOGS_EXPORTER to console is not supported by ddtrace, this configuration will be ignored.\n",
)
def test_otel_logs_exporter_configuration_unsupported():
from ddtrace import config # noqa: F401
Expand All @@ -233,8 +234,8 @@ def test_otel_resource_attributes_unified_tags():

@pytest.mark.subprocess(
env={"OTEL_RESOURCE_ATTRIBUTES": "deployment.environment:prod,service.name:bleh,service.version:1.0"},
err=b"DDTRACE failed to read OTEL_RESOURCE_ATTRIBUTES. This value is misformatted: "
b"deployment.environment:prod,service.name:bleh,service.version:1.0\n",
err=b"Setting OTEL_RESOURCE_ATTRIBUTES to deployment.environment:prod,service.name:bleh,service.version:1.0"
b" is not supported by ddtrace, this configuration will be ignored.\n",
)
def test_otel_resource_attributes_misconfigured_tags():
from ddtrace import config # noqa: F401
Expand Down

0 comments on commit f803a3c

Please sign in to comment.