Skip to content

feat(agent-config): add dd_org_uuid for delegated auth#137

Merged
duncanista merged 3 commits into
mainfrom
jordan.gonzalez/agent-config/dd-org-uuid
Jun 18, 2026
Merged

feat(agent-config): add dd_org_uuid for delegated auth#137
duncanista merged 3 commits into
mainfrom
jordan.gonzalez/agent-config/dd-org-uuid

Conversation

@duncanista

Copy link
Copy Markdown
Contributor

Summary

Adds a first-class `dd_org_uuid: String` field to the top-level `Config` struct in `datadog-agent-config`, sourced from the `DD_ORG_UUID` env var and the `org_uuid` key in `datadog.yaml`.

Why

Delegated auth via Datadog Org UUID is a generic Datadog SaaS auth-tier concept — it lets a component submit telemetry without a long-lived API key, by binding to an org rather than authenticating per call. It is not Lambda-specific.

Today `datadog-lambda-extension` carries this field inside its `LambdaConfig` extension. As more agents/embedders adopt this crate, every one of them would need to redefine the same field. Putting it upstream lets the lambda extension (and any future consumer) drop the local copy.

Behavior

  • Field: `Config::dd_org_uuid: String`, defaults to empty.
  • Env var: `DD_ORG_UUID` → `EnvConfig::org_uuid: Option`.
  • YAML key: `org_uuid` → `YamlConfig::org_uuid: Option`.
  • Both sources accept string or numeric form via `deserialize_string_or_int` for backwards compatibility.
  • Source field name (`org_uuid`) matches the env var / yaml key. Merges into config field `dd_org_uuid` using the existing `merge_string!` macro's 4-arg renaming form — same convention the lambda extension was already using internally.

Test plan

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

Follow-up

Once this lands and is pinned in `datadog-lambda-extension`, the extension can drop `dd_org_uuid` and `org_uuid` from its `LambdaConfig` / `LambdaConfigSource` and the local `merge_string!(self, dd_org_uuid, source, org_uuid)` call.

Adds first-class `dd_org_uuid: String` field to the top-level `Config`
struct, sourced from `DD_ORG_UUID` (env) and `org_uuid` (datadog.yaml).
Belongs upstream because delegated auth is a generic Datadog SaaS
auth-tier concept, not a Lambda-specific one. Currently re-implemented
inside `LambdaConfig` in datadog-lambda-extension; this lets the
extension drop its local definition in a follow-up.

- Accepts string or numeric form via `deserialize_string_or_int` for
  backwards compatibility with legacy callers.
- Source field name (`org_uuid`) matches the env var / yaml key; merges
  into the config field `dd_org_uuid` to match the existing convention
  the lambda extension was already using.
Copilot AI review requested due to automatic review settings June 18, 2026 19:03
@duncanista duncanista requested review from a team as code owners June 18, 2026 19:03
@duncanista duncanista requested review from Chronobreak and litianningdatadog and removed request for a team June 18, 2026 19:03
@duncanista

Copy link
Copy Markdown
Contributor Author

superseeds #112 tysm @jchrostek-dd

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 first-class support for Datadog Org UUID–based delegated authentication in datadog-agent-config by introducing a new resolved config field and wiring it up to existing env/YAML sources.

Changes:

  • Introduces Config::dd_org_uuid: String (default empty) on the top-level resolved config.
  • Adds org_uuid support to both env (DD_ORG_UUID) and YAML (org_uuid) sources and merges into dd_org_uuid.
  • Updates/extends env and YAML tests to cover the new field (including default + env override cases).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/datadog-agent-config/src/lib.rs Adds dd_org_uuid to the top-level Config struct and default initialization.
crates/datadog-agent-config/src/sources/env.rs Adds DD_ORG_UUIDorg_uuid parsing and merges into Config::dd_org_uuid, with new tests.
crates/datadog-agent-config/src/sources/yaml.rs Adds YAML org_uuid parsing and merges into Config::dd_org_uuid, updating YAML fixtures/expectations.

Comment thread crates/datadog-agent-config/src/sources/yaml.rs Outdated
Address Copilot review: replace the "see env.rs" pointer with the full
explanation inline so users reading the YAML source can understand the
key without cross-referencing.
/// delegated auth so the agent can submit telemetry without a long-lived
/// API key. Accepts a string or numeric form for backwards compatibility.
/// Merges into the resolved config field `dd_org_uuid`.
#[serde(deserialize_with = "deserialize_string_or_int")]

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.

Nit: could we clarify why we’re using deserialize_string_or_int instead of deserialize_optional_string here?

@duncanista duncanista Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good question — it is a carry-over. the field was first added in bottlecap by #1112 (john, delegated auth) with deserialize_string_or_int, and i preserved it verbatim when moving it upstream. the introducing pr does not explain the choice; it looks copy-pasted from the env/service/version pattern (those genuinely need string_or_int because users do set them to numeric values like "1.2").

for a uuid it makes no sense — uuids are hex + dashes, there is no numeric form. tightening to deserialize_optional_string also fail-fasts on misconfiguration instead of silently coercing. fixed in d4d6fd8.

A UUID is hex + dashes; there is no legitimate numeric form a user
would supply. The previous deserializer (deserialize_string_or_int)
was a carry-over from the bottlecap copy, where it appears to have
been copy-pasted from the env/service/version pattern. Tightening to
deserialize_optional_string fail-fasts on misconfiguration instead of
silently coercing.
@duncanista duncanista merged commit f76e911 into main Jun 18, 2026
27 checks passed
@duncanista duncanista deleted the jordan.gonzalez/agent-config/dd-org-uuid branch June 18, 2026 20:14
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