Skip to content

Commit 5f22c06

Browse files
committed
Switch to OTEL_LOG_LEVEL
1 parent ddaebe3 commit 5f22c06

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

docs/reference/edot-python/configuration.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,22 @@ EDOT Python uses different defaults than OpenTelemetry Python for the following
9494
| `OTEL_METRICS_EXEMPLAR_FILTER` | `always_off` | `trace_based` |
9595
| `OTEL_TRACES_SAMPLER` | `parentbased_traceidratio` | `parentbased_always_on` |
9696
| `OTEL_TRACES_SAMPLER_ARG` | `1.0` | |
97+
| `OTEL_LOG_LEVEL` | `warn` | Not handled |
9798

9899
:::{note}
99100
`OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` cloud resource detectors are dynamically set. When running in a Kubernetes Pod it will be set to `process_runtime,os,otel,telemetry_distro,service_instance,_gcp,aws_eks`.
100101
:::
101102

103+
:::{note}
104+
`OTEL_LOG_LEVEL` accepts the following levels: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `off`.
105+
:::
102106

103107
### Configuration options only available in EDOT Python
104108

105109
`ELASTIC_OTEL_` options are specific to Elastic and will always live in EDOT Python include the following.
106110

107111
| Option(s) | Default | Description |
108112
|---|---|---|
109-
| `ELASTIC_OTEL_LOG_LEVEL` | `warn` | Configure EDOT SDK logging level to one of `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `off` |
110113
| `ELASTIC_OTEL_SYSTEM_METRICS_ENABLED` | `false` | When set to `true`, sends *system namespace* metrics. |
111114

112115
## LLM settings

src/elasticotel/distro/config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
import os
2121
from dataclasses import dataclass
2222

23-
from elasticotel.distro.environment_variables import ELASTIC_OTEL_LOG_LEVEL
2423
from opentelemetry import trace
2524
from opentelemetry._opamp import messages
2625
from opentelemetry._opamp.agent import OpAMPAgent
2726
from opentelemetry._opamp.client import OpAMPClient
2827
from opentelemetry._opamp.proto import opamp_pb2 as opamp_pb2
29-
from opentelemetry.sdk.environment_variables import OTEL_TRACES_SAMPLER_ARG
28+
from opentelemetry.sdk.environment_variables import OTEL_LOG_LEVEL, OTEL_TRACES_SAMPLER_ARG
3029
from opentelemetry.sdk.trace.sampling import ParentBasedTraceIdRatio
3130

3231

@@ -82,9 +81,8 @@ class ConfigUpdate:
8281
@dataclass
8382
class Config:
8483
sampling_rate = ConfigItem(default=str(DEFAULT_SAMPLING_RATE), from_env_var=OTEL_TRACES_SAMPLER_ARG)
85-
# currently the sdk does not handle OTEL_LOG_LEVEL, so we use ELASTIC_OTEL_LOG_LEVEL
86-
# with the same values and behavior of the logging_level we get from Central Configuration.
87-
logging_level = ConfigItem(default=DEFAULT_LOGGING_LEVEL, from_env_var=ELASTIC_OTEL_LOG_LEVEL)
84+
# currently the sdk does not handle OTEL_LOG_LEVEL, so we use handle it on our own
85+
logging_level = ConfigItem(default=DEFAULT_LOGGING_LEVEL, from_env_var=OTEL_LOG_LEVEL)
8886

8987
def to_dict(self):
9088
return {LOGGING_LEVEL_CONFIG_KEY: self.logging_level.value, SAMPLING_RATE_CONFIG_KEY: self.sampling_rate.value}

src/elasticotel/distro/environment_variables.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,3 @@
3131
3232
**Default value:** ``not set``
3333
"""
34-
35-
ELASTIC_OTEL_LOG_LEVEL = "ELASTIC_OTEL_LOG_LEVEL"
36-
"""
37-
.. envvar:: ELASTIC_OTEL_LOG_LEVEL
38-
39-
EDOT and OpenTelemetry SDK logging level.
40-
41-
**Default value:** ``not set``
42-
"""

tests/distro/test_distro.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_configurator_ignores_opamp_without_endpoint(self, client_mock, agent_mo
235235
client_mock.assert_not_called()
236236
agent_mock.assert_not_called()
237237

238-
@mock.patch.dict("os.environ", {"ELASTIC_OTEL_LOG_LEVEL": "debug"}, clear=True)
238+
@mock.patch.dict("os.environ", {"OTEL_LOG_LEVEL": "debug"}, clear=True)
239239
@mock.patch("elasticotel.distro.config.logger")
240240
def test_configurator_applies_elastic_otel_log_level(self, logger_mock):
241241
ElasticOpenTelemetryConfigurator()._configure()
@@ -255,7 +255,7 @@ def test_configurator_handles_elastic_otel_log_level_not_set(self, logger_mock):
255255
self.assertEqual(logging.getLogger("opentelemetry").getEffectiveLevel(), logging.WARNING)
256256
self.assertEqual(logging.getLogger("elasticotel").getEffectiveLevel(), logging.WARNING)
257257

258-
@mock.patch.dict("os.environ", {"ELASTIC_OTEL_LOG_LEVEL": "invalid"}, clear=True)
258+
@mock.patch.dict("os.environ", {"OTEL_LOG_LEVEL": "invalid"}, clear=True)
259259
def test_configurator_handles_invalid_elastic_otel_log_level(self):
260260
with self.assertLogs("elasticotel", level="ERROR") as cm:
261261
ElasticOpenTelemetryConfigurator()._configure()

0 commit comments

Comments
 (0)