Skip to content

fix(dogstatsd): origin detection precedence for tag enrichment#41587

Merged
dd-mergequeue[bot] merged 3 commits intomainfrom
gabedos/origin-detection-refactor
Oct 6, 2025
Merged

fix(dogstatsd): origin detection precedence for tag enrichment#41587
dd-mergequeue[bot] merged 3 commits intomainfrom
gabedos/origin-detection-refactor

Conversation

@gabedos
Copy link
Copy Markdown
Contributor

@gabedos gabedos commented Oct 3, 2025

What does this PR do?

Updates tag enrichment logic for unified Dogstatsd to enrich on only one entity ID, based on precedence.

Motivation

#incident-41903. During OOM kills on busy hosts, origin detection fails on rare occasion causing incorrect metric contexts being generated.

To address these issues with duplicate/incorrect tag values from tag enrichment via origin detection, we’re changing the logic so that enrichment is based only on the highest-priority entity ID among all available IDs, rather than enriching separately on all container IDs and pod UIDs provided.

Assuming that the provided containerID is correct, then all subsequent calls for tag accumulation on the "hypothetically" same containerID and podUID should return the same values. Therefore we can exit out from tag enrichment after the first hit.

Describe how you validated your changes

Unit tests and CI

Additional Notes

Removed the OriginInfoContainerIDMismatch because we will stop at the first valid containerID for tagging now. Thus, this metric does not provide value anymore in knowing whether we have incorrect tags on telemetry. It could still be useful for identifying other system issues with receiving faulty data related to ExternalData.

For GenerateContainerIDFromOriginInfo we may want to consider also re-ordering the priority to use the Inode method as the second option and bumping down the more expensive and less reliable PIDtoCID method. Note, this doesn't affect DogStatsd, but rather other remote Agents that query the tagger such as trace-agent and process-agent.

// If the inode is known, do an inode resolution.
if originInfo.LocalData.Inode != 0 {
t.log.Debugf("Resolving container ID from inode: %d", originInfo.LocalData.Inode)
containerID, err = metaCollector.GetContainerIDForInode(originInfo.LocalData.Inode, inodeCacheTTL)
if err != nil {
t.log.Debugf("Error resolving container ID from inode: %v", err)
} else if containerID == "" {
t.log.Debugf("No container ID found for inode: %d", originInfo.LocalData.Inode)
} else {
return
}
}

@gabedos gabedos changed the title fix(dogstatsd): fix(dogstatsd): origin detection precedence for tag enrichment Oct 3, 2025
@github-actions github-actions bot added team/container-platform The Container Platform Team short review PR is simple enough to be reviewed quickly labels Oct 3, 2025
@gabedos gabedos added the qa/done QA done before merge and regressions are covered by tests label Oct 3, 2025
@gabedos gabedos marked this pull request as ready for review October 3, 2025 20:17
@gabedos gabedos requested review from a team as code owners October 3, 2025 20:17
@github-actions github-actions bot added medium review PR review might take time and removed short review PR is simple enough to be reviewed quickly labels Oct 3, 2025
@cit-pr-commenter
Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 6c2a51c6-6b9f-4f83-963e-258f1805345e

Baseline: 7936183
Comparison: eb91bad
Diff

Optimization Goals: ✅ No significant changes detected

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization -11.68 [-13.25, -10.12] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_memory memory utilization +3.38 [+2.96, +3.81] 1 Logs
quality_gate_logs % cpu utilization +1.99 [-0.83, +4.82] 1 Logs bounds checks dashboard
otlp_ingest_metrics memory utilization +0.61 [+0.49, +0.73] 1 Logs
quality_gate_idle memory utilization +0.21 [+0.17, +0.25] 1 Logs bounds checks dashboard
file_to_blackhole_500ms_latency egress throughput +0.04 [-0.57, +0.65] 1 Logs
uds_dogstatsd_to_api ingress throughput +0.02 [-0.22, +0.27] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.03 [-0.65, +0.58] 1 Logs
quality_gate_metrics_logs memory utilization -0.04 [-0.25, +0.17] 1 Logs bounds checks dashboard
ddot_metrics memory utilization -0.04 [-0.21, +0.12] 1 Logs
ddot_metrics_sum_cumulativetodelta_exporter memory utilization -0.07 [-0.26, +0.13] 1 Logs
file_to_blackhole_1000ms_latency egress throughput -0.09 [-0.70, +0.52] 1 Logs
file_tree memory utilization -0.10 [-0.14, -0.07] 1 Logs
ddot_metrics_sum_delta memory utilization -0.12 [-0.28, +0.03] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.13 [-0.73, +0.46] 1 Logs
quality_gate_idle_all_features memory utilization -0.25 [-0.29, -0.22] 1 Logs bounds checks dashboard
uds_dogstatsd_20mb_12k_contexts_20_senders memory utilization -0.26 [-0.32, -0.20] 1 Logs
ddot_logs memory utilization -0.29 [-0.35, -0.24] 1 Logs
ddot_metrics_sum_cumulative memory utilization -0.40 [-0.51, -0.28] 1 Logs
tcp_syslog_to_blackhole ingress throughput -0.56 [-0.64, -0.47] 1 Logs
otlp_ingest_logs memory utilization -1.06 [-1.18, -0.94] 1 Logs
docker_containers_cpu % cpu utilization -11.68 [-13.25, -10.12] 1 Logs

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
docker_containers_cpu simple_check_run 10/10
docker_containers_memory memory_usage 10/10
docker_containers_memory simple_check_run 10/10
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_100ms_latency lost_bytes 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle intake_connections 10/10 bounds checks dashboard
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs intake_connections 10/10 bounds checks dashboard
quality_gate_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_logs memory_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 bounds checks dashboard
quality_gate_metrics_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

@agent-platform-auto-pr
Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 7936183

Successful checks

Info

Quality gate Delta On disk size (MiB) Delta On wire size (MiB)
agent_deb_amd64 $${0}$$ $${701.27}$$ < $${703.13}$$ $${+0.01}$$ $${176.85}$$ < $${178.38}$$
agent_deb_amd64_fips $${-0}$$ $${695.77}$$ < $${697.61}$$ $${+0.05}$$ $${175.57}$$ < $${177.15}$$
agent_heroku_amd64 $${0}$$ $${339.41}$$ < $${341.62}$$ $${-0}$$ $${90.16}$$ < $${91.52}$$
agent_msi $${-0.01}$$ $${983.96}$$ < $${990.42}$$ $${0}$$ $${149.6}$$ < $${152.42}$$
agent_rpm_amd64 $${0}$$ $${701.26}$$ < $${703.12}$$ $${+0.03}$$ $${180.14}$$ < $${180.53}$$
agent_rpm_amd64_fips $${-0}$$ $${695.76}$$ < $${697.6}$$ $${+0.03}$$ $${177.88}$$ < $${178.87}$$
agent_rpm_arm64 $${-0}$$ $${685.44}$$ < $${689.82}$$ $${-0.02}$$ $${160.3}$$ < $${162.16}$$
agent_rpm_arm64_fips $${-0}$$ $${680.96}$$ < $${685.08}$$ $${+0.02}$$ $${159.24}$$ < $${161.11}$$
agent_suse_amd64 $${0}$$ $${701.26}$$ < $${703.12}$$ $${+0.03}$$ $${180.14}$$ < $${180.53}$$
agent_suse_amd64_fips $${-0}$$ $${695.76}$$ < $${697.6}$$ $${+0.03}$$ $${177.88}$$ < $${178.87}$$
agent_suse_arm64 $${-0}$$ $${685.44}$$ < $${689.82}$$ $${-0.02}$$ $${160.3}$$ < $${162.16}$$
agent_suse_arm64_fips $${-0}$$ $${680.96}$$ < $${685.08}$$ $${+0.02}$$ $${159.24}$$ < $${161.11}$$
docker_agent_amd64 $${+0}$$ $${772.71}$$ < $${774.54}$$ $${-0}$$ $${265.11}$$ < $${266.46}$$
docker_agent_arm64 $${-0}$$ $${780.83}$$ < $${785.2}$$ $${+0}$$ $${250.9}$$ < $${252.92}$$
docker_agent_jmx_amd64 $${+0}$$ $${963.58}$$ < $${965.41}$$ $${-0.01}$$ $${333.73}$$ < $${335.08}$$
docker_agent_jmx_arm64 $${-0}$$ $${960.3}$$ < $${964.66}$$ $${-0}$$ $${315.52}$$ < $${317.54}$$
docker_cluster_agent_amd64 $${-0}$$ $${212.81}$$ < $${213.74}$$ $${+0.01}$$ $${72.19}$$ < $${73.2}$$
docker_cluster_agent_arm64 $${-0}$$ $${228.73}$$ < $${229.68}$$ $${-0.01}$$ $${68.45}$$ < $${69.48}$$
docker_cws_instrumentation_amd64 $${0}$$ $${7.06}$$ < $${7.12}$$ $${+0}$$ $${2.95}$$ < $${3.29}$$
docker_cws_instrumentation_arm64 $${-0}$$ $${6.69}$$ < $${6.92}$$ $${-0}$$ $${2.7}$$ < $${3.07}$$
docker_dogstatsd_amd64 $${0}$$ $${38.35}$$ < $${39.3}$$ $${+0}$$ $${14.81}$$ < $${15.76}$$
docker_dogstatsd_arm64 $${-0.06}$$ $${37.0}$$ < $${37.94}$$ $${+0}$$ $${14.26}$$ < $${14.83}$$
dogstatsd_deb_amd64 $${0}$$ $${29.57}$$ < $${30.53}$$ $${-0}$$ $${7.8}$$ < $${8.75}$$
dogstatsd_deb_arm64 $${-0}$$ $${28.16}$$ < $${29.12}$$ $${-0}$$ $${6.75}$$ < $${7.71}$$
dogstatsd_rpm_amd64 $${0}$$ $${29.57}$$ < $${30.53}$$ $${-0}$$ $${7.81}$$ < $${8.77}$$
dogstatsd_suse_amd64 $${0}$$ $${29.57}$$ < $${30.53}$$ $${-0}$$ $${7.81}$$ < $${8.77}$$
iot_agent_deb_amd64 $${0}$$ $${54.51}$$ < $${54.97}$$ $${-0}$$ $${13.62}$$ < $${14.45}$$
iot_agent_deb_arm64 $${0}$$ $${51.8}$$ < $${51.9}$$ $${+0}$$ $${11.75}$$ < $${12.63}$$
iot_agent_deb_armhf $${0}$$ $${51.33}$$ < $${51.84}$$ $${-0}$$ $${11.82}$$ < $${12.74}$$
iot_agent_rpm_amd64 $${0}$$ $${54.51}$$ < $${54.97}$$ $${-0}$$ $${13.63}$$ < $${14.47}$$
iot_agent_suse_amd64 $${0}$$ $${54.51}$$ < $${54.97}$$ $${-0}$$ $${13.63}$$ < $${14.47}$$

@gabedos
Copy link
Copy Markdown
Contributor Author

gabedos commented Oct 6, 2025

/merge

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex bot commented Oct 6, 2025

View all feedbacks in Devflow UI.

2025-10-06 13:23:34 UTC ℹ️ Start processing command /merge


2025-10-06 13:23:39 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 43m (p90).


2025-10-06 13:48:21 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit cceb7fc into main Oct 6, 2025
277 checks passed
@dd-mergequeue dd-mergequeue bot deleted the gabedos/origin-detection-refactor branch October 6, 2025 13:48
@github-actions github-actions bot added this to the 7.73.0 milestone Oct 6, 2025
dd-octo-sts bot pushed a commit that referenced this pull request Oct 6, 2025
### What does this PR do?

Updates tag enrichment logic for unified Dogstatsd to enrich on only one entity ID, based on precedence.

### Motivation

#incident-41903. During OOM kills on busy hosts, origin detection fails on rare occasion causing incorrect metric contexts being generated.

To address these issues with duplicate/incorrect tag values from tag enrichment via origin detection, we’re changing the logic so that enrichment is based only on the highest-priority entity ID among all available IDs, rather than enriching separately on all container IDs and pod UIDs provided.

Assuming that the provided containerID is correct, then all subsequent calls for tag accumulation on the "hypothetically" same containerID and podUID should return the same values. Therefore we can exit out from tag enrichment after the first hit.

### Describe how you validated your changes

Unit tests and CI

### Additional Notes

Removed the `OriginInfoContainerIDMismatch` because we will stop at the first valid containerID for tagging now. Thus, this metric does not provide value anymore in knowing whether we have incorrect tags on telemetry. It could still be useful for identifying other system issues with receiving faulty data related to ExternalData.

For `GenerateContainerIDFromOriginInfo` we may want to consider also re-ordering the priority to use the Inode method as the second option and bumping down the more expensive and less reliable PIDtoCID method. Note, this doesn't affect DogStatsd, but rather other remote Agents that query the tagger such as trace-agent and process-agent.

https://github.com/DataDog/datadog-agent/blob/fc2014a0f3c1a5a3df8736a6663f7ba90328ab65/comp/core/tagger/impl/tagger.go#L257-L269
(cherry picked from commit cceb7fc)
AliDatadog pushed a commit that referenced this pull request Oct 6, 2025
… enrichment (#41644)

Backport cceb7fc from #41587.

___

### What does this PR do?

Updates tag enrichment logic for unified Dogstatsd to enrich on only one
entity ID, based on precedence.

### Motivation

#incident-41903. During OOM kills on busy hosts, origin detection fails
on rare occasion causing incorrect metric contexts being generated.

To address these issues with duplicate/incorrect tag values from tag
enrichment via origin detection, we’re changing the logic so that
enrichment is based only on the highest-priority entity ID among all
available IDs, rather than enriching separately on all container IDs and
pod UIDs provided.

Assuming that the provided containerID is correct, then all subsequent
calls for tag accumulation on the &quot;hypothetically&quot; same
containerID and podUID should return the same values. Therefore we can
exit out from tag enrichment after the first hit.

### Describe how you validated your changes

Unit tests and CI

### Additional Notes

Removed the `OriginInfoContainerIDMismatch` because we will stop at the
first valid containerID for tagging now. Thus, this metric does not
provide value anymore in knowing whether we have incorrect tags on
telemetry. It could still be useful for identifying other system issues
with receiving faulty data related to ExternalData.

For `GenerateContainerIDFromOriginInfo` we may want to consider also
re-ordering the priority to use the Inode method as the second option
and bumping down the more expensive and less reliable PIDtoCID method.
Note, this doesn&#39;t affect DogStatsd, but rather other remote Agents
that query the tagger such as trace-agent and process-agent.


https://github.com/DataDog/datadog-agent/blob/fc2014a0f3c1a5a3df8736a6663f7ba90328ab65/comp/core/tagger/impl/tagger.go#L257-L269

Co-authored-by: Gabriel Dos Santos <91925154+gabedos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/container-platform The Container Platform Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants