Skip to content

feat(agent-config): add logs_enabled master toggle#138

Merged
duncanista merged 2 commits into
mainfrom
jordan.gonzalez/agent-config/logs-enabled
Jun 18, 2026
Merged

feat(agent-config): add logs_enabled master toggle#138
duncanista merged 2 commits into
mainfrom
jordan.gonzalez/agent-config/logs-enabled

Conversation

@duncanista

Copy link
Copy Markdown
Contributor

Summary

Adds the canonical dd-agent.yaml top-level `logs_enabled: bool` field to the upstream `Config` struct, sourced from `DD_LOGS_ENABLED` (env) and `logs_enabled` (datadog.yaml).

Why

The dd-agent template (config_template.yaml:1215-1219) documents `logs_enabled` / `DD_LOGS_ENABLED` as the master toggle for log collection. The upstream Rust crate has scoped variants (`observability_pipelines_worker_logs_enabled`, `otlp_config_logs_enabled`) but not the canonical top-level switch.

Today `datadog-lambda-extension` works around this by carrying `logs_enabled` as a source-side alias on its `LambdaConfigSource` that OR-merges into a separate `serverless_logs_enabled` field. With the toggle upstream, the extension (and any future embedder) gets a real resolved config field instead of a synthesized one. The lambda extension will keep `serverless_logs_enabled` for backwards compatibility with `DD_SERVERLESS_LOGS_ENABLED`, but call sites can check both fields directly.

Behavior

  • Field: `Config::logs_enabled: bool`, defaults to `false` (matches dd-agent).
  • Env var: `DD_LOGS_ENABLED` → `EnvConfig::logs_enabled: Option`.
  • YAML key: top-level `logs_enabled` → `YamlConfig::logs_enabled: Option`.
  • Both deserialized via `deserialize_optional_bool_from_anything` (graceful fallback on bad input — same pattern as other bool fields).

Test plan

  • `cargo test -p datadog-agent-config --all-targets` — 75 passed (was 73; +2 new tests covering env-var override + default-false-when-unset)
  • `cargo clippy -p datadog-agent-config --all-targets` — clean
  • `cargo fmt -p datadog-agent-config -- --check` — clean
  • Added `DD_LOGS_ENABLED` to the all-types-broken-fallback test in env.rs and the matching yaml.rs broken-fallback test; both pass.

Follow-up

Once this lands and is pinned in `datadog-lambda-extension`, the extension can:

  • Drop the `logs_enabled` alias source field from `LambdaConfigSource`.
  • Drop the OR-merge in `merge_from`.
  • Have call sites check `config.logs_enabled || config.ext.serverless_logs_enabled` (preserving the existing OR semantics, with the lambda default of `true` retained on the extension side).

Adds the canonical dd-agent.yaml top-level `logs_enabled: bool` field to
the upstream `Config` struct, sourced from `DD_LOGS_ENABLED` (env) and
`logs_enabled` (datadog.yaml). Matches dd-agent's
pkg/config/config_template.yaml documentation and defaults to `false`.

Currently the lambda extension carries this as a source-side alias on
its `LambdaConfigSource` that OR-merges into a separate
`serverless_logs_enabled` field. Pushing `logs_enabled` upstream means
consumers (lambda extension and any future embedder) have a real
resolved config field for the canonical dd-agent toggle, instead of
synthesizing one.
Copilot AI review requested due to automatic review settings June 18, 2026 20:33
@duncanista duncanista requested review from a team as code owners June 18, 2026 20:33
@duncanista duncanista requested review from Lewis-E and lym953 and removed request for a team June 18, 2026 20:33

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.

Pull request overview

Adds the canonical top-level logs_enabled master toggle to the resolved Config in datadog-agent-config, sourcing it from DD_LOGS_ENABLED (env) and logs_enabled (datadog.yaml) with default false to match dd-agent behavior.

Changes:

  • Introduces Config::logs_enabled: bool with default false.
  • Wires logs_enabled into both YAML and env sources via deserialize_optional_bool_from_anything and merges into the resolved config.
  • Extends existing tests and adds env-focused tests for override + default behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/datadog-agent-config/src/sources/yaml.rs Adds YAML logs_enabled parsing/merge and updates YAML tests/fixtures.
crates/datadog-agent-config/src/sources/env.rs Adds env DD_LOGS_ENABLED parsing/merge and adds tests for env override + default-unset behavior.
crates/datadog-agent-config/src/lib.rs Adds resolved Config::logs_enabled field and default initialization.

Comment thread crates/datadog-agent-config/src/sources/yaml.rs
Comment thread crates/datadog-agent-config/src/sources/yaml.rs
Address Copilot review: in the yaml broken-fallback test, every non-string
field is set to an invalid type (e.g. [1, 2, 3]) to exercise graceful
fallback to defaults. logs_enabled was inadvertently set to a valid
boolean (true), which defeated the test's intent for this new field.

Set it to [1, 2, 3] and assert the resolved value stays at the default
(false). Now the test fails if graceful-fallback handling for
logs_enabled ever regresses.
@duncanista duncanista merged commit 8ce37eb into main Jun 18, 2026
27 checks passed
@duncanista duncanista deleted the jordan.gonzalez/agent-config/logs-enabled branch June 18, 2026 20:41
duncanista added a commit to DataDog/datadog-lambda-extension that referenced this pull request Jun 18, 2026
…lias

Upstream DataDog/serverless-components#138 landed `Config::logs_enabled`
as a top-level field sourced from `DD_LOGS_ENABLED` / `logs_enabled`
(yaml), default `false`. Bumps the pin from f76e911 -> 8ce37eb.

The lambda extension's existing OR-merge contract is preserved exactly:
DD_SERVERLESS_LOGS_ENABLED and DD_LOGS_ENABLED are still OR-merged into
config.ext.serverless_logs_enabled, and the default-true is still kept
only when neither env var is explicitly set. To do that without losing
"was DD_LOGS_ENABLED explicitly set?" information, the alias source
field on LambdaConfigSource is retained — the upstream parsing of the
same env var into config.logs_enabled is intentional and runs in
parallel for non-lambda consumers.

Lambda call sites continue to gate log shipping on
config.ext.serverless_logs_enabled. No behavior change for customers.

Adds a regression test for the "DD_LOGS_ENABLED=false alone disables
logs" edge case so a future refactor that breaks it fails loudly.
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.

3 participants