-
Notifications
You must be signed in to change notification settings - Fork 440
chore: configurable logger levels #13562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
We introduce private enviornment variables that allow configuring the log level of the ddtrace loggers. This allows for fine-grained control over the logger levels, making debugging easier by reducing the noise of logs.
|
Bootstrap import analysisComparison of import times between this PR and base. SummaryThe average import time from this PR is: 279 ± 6 ms. The average import time from base is: 281 ± 7 ms. The import time difference between this PR and base is: -1.7 ± 0.3 ms. Import time breakdownThe following import paths have appeared:
|
BenchmarksBenchmark execution time: 2025-06-12 17:01:51 Comparing candidate commit e9ae14d in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 555 metrics, 6 unstable metrics. scenario:iastaspectsospath-ospathsplitdrive_aspect
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests?
I can add them if we're all onboard with merging this change 🙂 |
print(dd_logger.LOG_LEVEL_TRIE) | ||
|
||
try: | ||
assert get_logger("ddtrace.testing.debug.foo.bar").level == logging.DEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't have to manually set the level for all children.... right?
meaning _DD_TESTING_DEBUG_LOG_LEVEL=DEBUG
should only set the level on testing.debug
only, and not on .foo
or .foo.bar
.
You should evaluate via .isEnabledFor(logging.DEBUG)
instead of .level == logging.DEBUG
, since that takes into account it's parents settings as well:
>>> a = logging.getLogger("a")
>>> b = logging.getLogger("a.b")
>>> a.setLevel(logging.DEBUG)
>>> b.isEnabledFor(logging.DEBUG)
True
>>> a.setLevel(logging.ERROR)
>>> b.isEnabledFor(logging.DEBUG)
False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's a good point, but what if the logger for a
is never created? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me
We introduce private enviornment variables that allow configuring the log level of the ddtrace loggers. This allows for fine-grained control over the logger levels, making debugging easier by reducing the noise of logs. For example, setting
_DD_DEBUGGING_LOG_LEVEL=DEBUG
would enable debug logs for any loggers underddtrace.debugging
only.Checklist
Reviewer Checklist