Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/reference/edot-python/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ Instrument Python `logging` module to format and forward logs in OTLP format is
export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
```

:::{note}
Turning this on will make any call to [logging.basicConfig](https://docs.python.org/3/library/logging.html#logging.basicConfig) from your application a no-op.
:::

#### Differences from OpenTelemetry Python

EDOT Python uses different defaults than OpenTelemetry Python for the following configuration options:
Expand Down
9 changes: 9 additions & 0 deletions src/elasticotel/distro/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"debug": logging.DEBUG,
"info": logging.INFO,
"warn": logging.WARNING,
"warning": logging.WARNING,
"error": logging.ERROR,
"fatal": logging.CRITICAL,
"off": 1000,
Expand Down Expand Up @@ -99,9 +100,17 @@ def log_env_vars(self):
for k, v in os.environ.items()
if k.startswith("OTEL_") or k.startswith("ELASTIC_OTEL_")
]
# we rely on the application setting up logging and we don't want to interfere with that BUT:
# - by default the python root logger should be at WARNING level
# - the EDOT Configuration dump is at INFO level
# - at startup we don't have application logging already setup
# So we add a temporary handler just for printing our config
handler = logging.StreamHandler()
logger.addHandler(handler)
logger.info("EDOT Configuration")
for k, v in sorted(env_vars):
logger.info("%s: %s", k, v)
logger.handlers.remove(handler)

def _handle_logging(self):
# do validation, we only validate logging_level because sampling_rate is handled by the sdk already
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,19 @@ def test_script():
self.assertFalse(telemetry["traces"])
self.assertTrue(telemetry["logs"])

def test_configuration_dump_at_startup_with_info_level(self):
def test_script():
pass

env = {"OTEL_LOG_LEVEL": "info", "OTEL_ENV_VAR": "value"}
stdout, stderr, returncode = self.run_script(
test_script, environment_variables=env, wrapper_script="opentelemetry-instrument"
)

assert "EDOT Configuration" in stderr
assert "OTEL_LOG_LEVEL: info" in stderr
assert "OTEL_ENV_VAR: value" in stderr


@pytest.mark.integration
class HTTPIntegrationTestCase(ElasticIntegrationHTTPTestCase):
Expand Down
Loading