Skip to content

[SVLS-9883] feat(config): accept filter directives in DD_LOG_LEVEL - #178

Closed
lym953 wants to merge 2 commits into
mainfrom
yiming.luo/log-level-directives
Closed

lym953 wants to merge 2 commits into
mainfrom
yiming.luo/log-level-directives

Conversation

@lym953

@lym953 lym953 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

The DD_LOG_LEVEL deserializer in datadog-agent-config accepts a RUST_LOG-style directive list, such as info,cold_start_duration=debug, without an error. The parsed level is the last entry that has no target, or warn if no entry is a plain level. Warn is also the fallback for an invalid value. A plain level and an invalid value, such as verbose, behave the same as before.

Motivation

What is true today: this crate parses DD_LOG_LEVEL as one level, such as debug. For any other value, it logs Invalid log level: '<value>' at ERROR and uses warn. No code reads the parsed log_level field.

What DataDog/datadog-lambda-extension#1413 adds: the Lambda extension accepts a list of filter directives in DD_LOG_LEVEL, such as info,cold_start_duration=debug. With it, a user can turn on debug logs for one tracing target only. This follows two existing Datadog components:

  • The Agent Data Plane, in DataDog/saluki, accepts directives in DD_LOG_LEVEL.
  • datadog-serverless-compat, in this repository, gives the DD_LOG_LEVEL value to its log filter, so directives work there too.

The problem: the extension also loads this crate. So with #1413, a directive list makes this crate log the ERROR at each cold start, although the extension uses the value correctly. This PR removes that false ERROR.

Additional Notes

The parser does not check the directives. The extension parses them with tracing-subscriber and logs a warning for each entry that does not parse.

Describe how to test/QA your changes

  1. Run cargo test -p datadog-agent-config --lib log_level. The four new unit tests and the existing test_parse_log_level pass.
  2. Build the Lambda extension from #1413, with this commit as the serverless-components revision. Run 2 cold starts for each value below.
DD_LOG_LEVEL ERROR lines with the current revision ERROR lines with this commit
info,cold_start_duration=debug 2 0
debug,cold_start_duration=off 2 0
debug 0 0

cargo test --locked fails on main before this change, because Cargo.lock needs an update. I ran the tests without --locked and did not commit the lock file changes.

🤖 Generated with Claude Code

@lym953

lym953 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Clippy errors are irrelevant. They will be fixed in #179.

@lym953
lym953 marked this pull request as ready for review October 7, 2026 20:15
Copilot AI balanced review requested due to automatic review settings October 7, 2026 20:15
@lym953
lym953 requested review from a team as code owners October 7, 2026 20:15
@lym953
lym953 requested review from apiarian-datadog and litianningdatadog and removed request for a team October 7, 2026 20:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change matches the stated behavior, includes relevant tests, and has no identified blocking issues.

0 open findings

What changed in this PR

Updates datadog-agent-config to accept filter directives in DD_LOG_LEVEL, avoiding false errors when used with the Lambda extension.

Changes:

  • Uses the last plain level in a directive list, defaulting to warn.
  • Preserves existing plain-level and invalid-value behavior.
  • Adds four focused deserialization tests.
File Description
crates/​datadog-agent-config/​src/​deserializers/​log_level.rs Accepts directive lists and tests level selection and fallbacks.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

lym953 and others added 2 commits October 8, 2026 12:32
A value such as `info,cold_start_duration=debug` is a RUST_LOG-style
directive list, which the Lambda extension and datadog-serverless-compat
pass to their log filter. Take the level from its entry with no target,
or info if there is none, and do not log "Invalid log level" for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the fallback for an invalid value, so the crate uses one default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lym953
lym953 force-pushed the yiming.luo/log-level-directives branch from 77adbb7 to 254e9bd Compare October 8, 2026 16:34
@lym953
lym953 requested a balanced review from Copilot and removed request for a team, apiarian-datadog and litianningdatadog October 8, 2026 18:58
@lym953
lym953 requested review from a team and shreyamalpani October 8, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change matches the intended compatibility behavior, with no blocking issues identified.

0 open findings

🧠 Review effort: Balanced

@lym953
lym953 marked this pull request as draft October 9, 2026 15:50
@lym953

lym953 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing. Will use a new env var DD_LOG_LEVEL_BY_TARGET.

@lym953 lym953 closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants