Skip to content

Wire OTLP Trace Metrics Writers into Metrics Aggregators#11680

Open
mhlidd wants to merge 7 commits into
mhlidd/update_hostname_metric_resource_attributesfrom
mhlidd/otlp_trace_metrics_factory_wiring
Open

Wire OTLP Trace Metrics Writers into Metrics Aggregators#11680
mhlidd wants to merge 7 commits into
mhlidd/update_hostname_metric_resource_attributesfrom
mhlidd/otlp_trace_metrics_factory_wiring

Conversation

@mhlidd

@mhlidd mhlidd commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

This PR wires the OTLP Trace Metrics logic and writers into the existing Metrics Aggregators used for Client Side Stats.

This involves:

  • Adding a new OTLP export variant for ConflatingMetricsAggregator which uses the OtlpStatsMetricWriter introduced in Define OTLP Trace Metrics Histogram and Writers #11656
  • Making native CSS metrics mutually exclusive w/ OTLP Trace Metrics
  • Dropping sampled traces when OTLP Trace Metrics is active
  • Adding the Datadog-Client-Computed-Stats header when OTLP Trace Metrics are active to prevent dual writing in the Agent
  • Adding package-private getters in ConflatingMetricsAggregator for testing purposes

Motivation

Additional Notes

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@mhlidd mhlidd changed the base branch from master to mhlidd/update_hostname_metric_resource_attributes June 18, 2026 21:59
@datadog-datadog-prod-us1

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.00 s 13.97 s [-0.6%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 12.91 s 12.95 s [-1.0%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 16.99 s 16.91 s [-0.6%; +1.6%] (no difference)
startup:petclinic:iast:Agent 16.95 s 16.94 s [-0.7%; +0.9%] (no difference)
startup:petclinic:profiling:Agent 17.04 s 16.88 s [-0.3%; +2.1%] (no difference)
startup:petclinic:sca:Agent 16.86 s 16.08 s [+0.5%; +9.2%] (maybe worse)
startup:petclinic:tracing:Agent 16.16 s 16.07 s [-0.6%; +1.6%] (no difference)

Commit: 3d2a0887 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@mhlidd mhlidd changed the title Mhlidd/otlp trace metrics factory wiring Wire OTLP Trace Metrics Writers into Metrics Aggregators Jul 1, 2026
@mhlidd mhlidd added comp: metrics Metrics type: enhancement Enhancements and improvements labels Jul 1, 2026
@mhlidd mhlidd marked this pull request as ready for review July 1, 2026 19:52
@mhlidd mhlidd requested a review from a team as a code owner July 1, 2026 19:52
@mhlidd mhlidd requested review from PerfectSlayer and mcculls July 1, 2026 19:52

@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: 9be5584c2a

ℹ️ 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".

return maps
}

def "Datadog-Client-Computed-Stats header set when either stats pipeline is enabled (otlpSpanMetrics=#otlpSpanMetrics, nativeMetrics=#nativeMetrics)"() {

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 Move the new stats-header coverage to JUnit 5

The root AGENTS.md says, "Always use JUnit 5" and "Do not write new Groovy / Spock tests"; this adds a new Spock feature method to DDAgentApiTest.groovy. Please move this coverage to a JUnit 5 test (or migrate the existing file) instead of adding new Groovy/Spock test code.

Useful? React with 👍 / 👎.

Comment on lines +34 to +35
return new ConflatingMetricsAggregator(
config, sharedCommunicationObjects, healthMetrics, new OtlpStatsMetricWriter(config));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid enabling OTLP stats without a sender

For traces.span.metrics.enabled=true with otlp.metrics.protocol=http/json, OtlpStatsMetricWriter.createSender returns null and finishBucket() drops the payload, but this factory still selects the OTLP stats aggregator. On the DD-agent writer path, the same config also marks Datadog-Client-Computed-Stats true and activates p0 dropping, so no SDK stats are delivered and the agent is told not to compute them either; gate this selection on a supported OTLP metrics transport or fall back instead.

Useful? React with 👍 / 👎.

@mhlidd mhlidd force-pushed the mhlidd/update_hostname_metric_resource_attributes branch from eefcc42 to a00f34b Compare July 2, 2026 21:11
@mhlidd mhlidd force-pushed the mhlidd/otlp_trace_metrics_factory_wiring branch from 9be5584 to 3d2a088 Compare July 3, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: metrics Metrics type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant