CORE-916: dynamically enable debug logs on python agent#209
Conversation
9c0a652 to
60ed280
Compare
| logger = logging.getLogger(logger_name) | ||
| if level is None: | ||
| # No level configured for this logger, so silence it. | ||
| logger.disabled = True |
There was a problem hiding this comment.
check if the default is INFO or disabled
There was a problem hiding this comment.
The default ODIGOS_LOG_LEVEL or OTEL_LOG_LEVEL is non existent, so it is None. So in this case this fits that None -> disable log.
Makes sense to me since we don't want to print any logs to the customer's app if we do not explicitely state so
3f13629 to
040c379
Compare
| logger = logging.getLogger(logger_name) | ||
| if level is None: | ||
| # No level configured for this logger, so silence it. | ||
| logger.disabled = True |
There was a problem hiding this comment.
The default ODIGOS_LOG_LEVEL or OTEL_LOG_LEVEL is non existent, so it is None. So in this case this fits that None -> disable log.
Makes sense to me since we don't want to print any logs to the customer's app if we do not explicitely state so
| but the trace-id format may be lost for those apps. | ||
| """ | ||
| # WARNING is the root logger's constructed default; LoggingInstrumentor changed it to INFO. | ||
| logging.getLogger().setLevel(logging.WARNING) |
There was a problem hiding this comment.
Clarifying comment:
This reverts the logging level back to warning, which is the logging library default
| original_basic_config = logging.basicConfig | ||
|
|
||
| def basic_config_relay(*args, **kwargs): | ||
| level = kwargs.get("level") | ||
| if level is not None: | ||
| logging.getLogger().setLevel(level) | ||
| # Keep the trace-id format the instrumentor installed; ignore the app's format override. | ||
| kwargs.pop("format", None) | ||
| return original_basic_config(*args, **kwargs) |
There was a problem hiding this comment.
Clarifying comment:
Some frameworks use basicConfig vs. setLevel for definng logging behavor.
We get the original basic config that was set by whatever framework (django, fastapi, etc) and re-apply it to get the log level it has set, but ignore the "format" part so we still get our trace id correlaton e.g.:
2026-06-29 08:50:33,385 INFO [root] [main.py:56] [trace_id=bea3462329d56c9768843d5746b12d0a span_id=88f8cb66fa405afe resource.service.name=inventory trace_sampled=True] - Buying product with id 40(the "trace_id = ..." part)
34c090c to
25c1ec6
Compare
| _set_logger_level(OPENTELEMETRY_LOGGER_NAME, _CONFIG_LEVEL_MAP.get(agent_diagnostics.get("openTelemetryComponentsLogLevel"))) | ||
|
|
||
|
|
||
| def relay_application_log_level() -> None: |
There was a problem hiding this comment.
review w tamir: we might not need this now
25c1ec6 to
ce9985f
Compare
ce9985f to
c00dc48
Compare
What this PR does / why we need it:
adds support for agent diagnostics for python (like we just added in node)
Changelog entry: Does this PR introduce a user-facing bug fix, feature, dependency update, or breaking change??