Skip to content

fix(dogstatsd): always set DSD environment variables on Core Agent container#3032

Merged
tobz merged 4 commits into
mainfrom
tobz/adp-dsd-env-vars-on-core-agent
May 21, 2026
Merged

fix(dogstatsd): always set DSD environment variables on Core Agent container#3032
tobz merged 4 commits into
mainfrom
tobz/adp-dsd-env-vars-on-core-agent

Conversation

@tobz

@tobz tobz commented May 20, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This PR updates the dogstatsd feature to set the relevant DSD-specific environment variables on the Core Agent container whether or not ADP is enabled.

Motivation

Originally, based on how ADP worked, we needed to do the conditional split: add DSD settings directly on the ADP container when enabled. However, with ADP 1.0.0, this has changed: Core Agent authoritatively provides configuration to ADP, and so we want all configuration to be provided to the Core Agent, which then provides it to ADP.

As such, we need to move these environment variables back to the Core Agent container to ensure they flow to ADP as intended.

Additional Notes

Anything else we should know when reviewing?

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

To be updated.

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label
  • All commits are signed (see: signing commits)

@tobz tobz added this to the v1.27.0 milestone May 20, 2026
@tobz
tobz requested a review from a team May 20, 2026 16:33
@tobz tobz added the bug Something isn't working label May 20, 2026
@tobz
tobz requested a review from a team as a code owner May 20, 2026 16:33
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented May 20, 2026

Copy link
Copy Markdown

Code Coverage

🎯 Code Coverage (details)
Patch Coverage: 95.00%
Overall Coverage: 42.54% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: fde94ea | Docs | Datadog PR Page | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 327da97917

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 225 to 229
managers.EnvVar().AddEnvVarToContainer(apicommon.CoreAgentContainerName, &corev1.EnvVar{
// defaults to 8125 in datadog-agent code
Name: DDDogstatsdPort,
Value: strconv.Itoa(dsdPortEnvVarValue),
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve ADP-side DogStatsD config on non-delegating agents

This refactor hard-codes DogStatsD settings onto the Core Agent container, but for the !f.agentSupportsADPDelegation path we still explicitly disable Core DogStatsD (DD_USE_DOGSTATSD=false). In that version window (Agent < 7.75), the ADP container no longer receives direct DogStatsD config (port/socket/origin/tag-cardinality/mapper settings), so enabling data plane DogStatsD can leave ADP running with defaults while the Core server is turned off. Please keep routing config to AgentDataPlaneContainerName for non-delegating agents, or gate the Core-only behavior by delegation support.

Useful? React with 👍 / 👎.

@codecov-commenter

codecov-commenter commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 42.24%. Comparing base (20ecb9e) to head (fde94ea).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ntroller/datadogagent/feature/dogstatsd/feature.go 94.73% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3032      +/-   ##
==========================================
+ Coverage   41.50%   42.24%   +0.73%     
==========================================
  Files         335      337       +2     
  Lines       28714    29421     +707     
==========================================
+ Hits        11919    12430     +511     
- Misses      16001    16181     +180     
- Partials      794      810      +16     
Flag Coverage Δ
unittests 42.24% <94.73%> (+0.73%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ntroller/datadogagent/feature/dogstatsd/feature.go 75.00% <94.73%> (+2.27%) ⬆️

... and 10 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20ecb9e...fde94ea. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…s DSD

When ADP is enabled and handling DogStatsD, the UDP port binding (including
HostPort) must go to the agent-data-plane container, not the Core Agent.
Previously the refactor to always set DSD env vars on Core Agent inadvertently
moved the port binding too. This restores the correct behaviour: env vars go
to Core Agent; the port binding goes to ADP when ADP is active.

Also adds a unit test covering this.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@tbavelier
tbavelier force-pushed the tobz/adp-dsd-env-vars-on-core-agent branch from 4e1f3b4 to fde94ea Compare May 21, 2026 09:52
@tobz
tobz merged commit efb068e into main May 21, 2026
38 checks passed
@tobz
tobz deleted the tobz/adp-dsd-env-vars-on-core-agent branch May 21, 2026 11:54
tbavelier pushed a commit that referenced this pull request May 21, 2026
…ntainer (#3032) (#3034)

(cherry picked from commit efb068e)

Co-authored-by: Toby Lawrence <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants