feat: implement additional metric tags for trace stats#140
Open
duncanpharvey wants to merge 7 commits into
Open
feat: implement additional metric tags for trace stats#140duncanpharvey wants to merge 7 commits into
duncanpharvey wants to merge 7 commits into
Conversation
duncanpharvey
force-pushed
the
duncan-harvey/trace-stats-additional-metric-tags
branch
from
June 29, 2026 14:11
6fae257 to
e38ada5
Compare
This comment has been minimized.
This comment has been minimized.
duncanpharvey
force-pushed
the
duncan-harvey/trace-stats-additional-metric-tags
branch
from
June 29, 2026 16:05
e38ada5 to
ec966d8
Compare
duncanpharvey
force-pushed
the
duncan-harvey/trace-stats-additional-metric-tags
branch
from
July 6, 2026 17:02
ec966d8 to
9ed7705
Compare
duncanpharvey
marked this pull request as ready for review
July 6, 2026 20:08
duncanpharvey
requested review from
Lewis-E and
jchrostek-dd
and removed request for
a team
July 6, 2026 20:08
Contributor
There was a problem hiding this comment.
Pull request overview
Implements support for sending additional metric tags on trace stats by introducing new configuration settings (gated behind an experimental flag) and wiring them into the trace stats concentrator, along with updating the libdatadog dependency revision required for the feature.
Changes:
- Add
DD_TRACE_EXPERIMENTAL_FEATURES_ENABLED,DD_TRACE_STATS_ADDITIONAL_TAGS, andDD_TRACE_STATS_ADDITIONAL_TAGS_CARDINALITY_LIMITparsing to trace-agent config (with unit tests for gating). - Update stats concentrator creation to pass additional metric tags + optional cardinality limit, and introduce a hashable key wrapper for
TracerMetadata. - Bump libdatadog git revs across crates and update lockfile / third-party license list accordingly.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| LICENSE-3rdparty.csv | Adds newly introduced transitive dependencies to the third-party license inventory. |
| crates/datadog-trace-agent/src/trace_processor.rs | Updates tests/struct construction to include newly added config fields and payload field. |
| crates/datadog-trace-agent/src/stats_concentrator_service.rs | Passes additional metric tags + cardinality limit into SpanConcentrator and updates metadata keying. |
| crates/datadog-trace-agent/src/config.rs | Adds experimental flag + additional tag settings, with unit tests for gating behavior. |
| crates/datadog-trace-agent/Cargo.toml | Bumps libdatadog git revision to pick up required upstream changes. |
| crates/datadog-serverless-compat/Cargo.toml | Bumps libdatadog git revision for trace utils. |
| crates/datadog-metrics-collector/Cargo.toml | Bumps libdatadog git revision for common utilities. |
| crates/datadog-agent-config/Cargo.toml | Bumps libdatadog git revision for trace utils/obfuscation. |
| Cargo.lock | Locks new upstream libdatadog revisions and new transitive crates introduced by the update. |
Lewis-E
approved these changes
Jul 7, 2026
gh-worker-dd-mergequeue-cf854d Bot
pushed a commit
to DataDog/libdatadog
that referenced
this pull request
Jul 21, 2026
…2170) # What does this PR do? - Add additional metric tags to the stats aggregation key. For each configured key, the matching span meta tag is included in the key and populates `ClientGroupedStats.additional_metric_tags`. - Limit the number of keys for `additional_metric_tags` to 4, not configurable. - Limit the maximum length of individual additional_metric_tags values to 200 characters, not configurable. Values exceeding this are replaced with `tracer_blocked_value`. # Motivation - Allow Serverless Compatibility Layer to send additional metric tags on trace stats. See [RFC](https://datadoghq.atlassian.net/wiki/spaces/APM/pages/6482919540/PENDING+Span-Derived+Primary+Tags+-+V1). - DataDog/serverless-components#140 to follow. - https://datadoghq.atlassian.net/browse/SVLS-8787 # Additional Notes Additional metric tags still need to be implemented in libdd-data-pipeline. Omitted from this PR since the goal of this PR is to support additional metric tags tags for Serverless without affecting other teams. https://github.com/DataDog/libdatadog/blob/42e3296aa3fa76749caf5d96b5bbf1ff2b1913b6/libdd-data-pipeline/src/trace_exporter/stats.rs#L146 Per-field cardinality limit for additional metric tags will be implemented in a following PR, #2211. - Limit the number of distinct aggregation entries per bucket that carry additional metric tags to 100 by default, configurable via `additional_metric_tags_max_entries`. Once exceeded, new entries have their tag values masked to `tracer_blocked_value`. --- Implementing additional metric tags instead of span derived primary tags. See previous PR for span derived primary tags - #1815. # How to test the change? - Unit tests - Deploy to Azure Functions with the following environment variables and validate that additional tags appear on trace metrics * `DD_TAGS: custom.primary:val,workload:azure_functions` * `DD_TRACE_EXPERIMENTAL_FEATURES_ENABLED: true` * `DD_TRACE_STATS_ADDITIONAL_TAGS: custom.primary,workload` <img width="685" height="411" alt="Screenshot 2026-07-06 at 3 39 47 PM" src="https://github.com/user-attachments/assets/b91495b6-11aa-4051-922f-63655666c4e5" /> Co-authored-by: duncan.harvey <duncan.harvey@datadoghq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
DD_TRACE_STATS_ADDITIONAL_TAGSsetting for adding additional tags to trace stats.DD_TRACE_STATS_ADDITIONAL_TAGS_CARDINALITY_LIMITto limit number of distinct stats entries (default of 100 inlibdd-trace-statsif no value is passed).DD_TRACE_EXPERIMENTAL_FEATURES_ENABLEDto gate the behavior behindDD_TRACE_STATS_ADDITIONAL_TAGSandDD_TRACE_STATS_ADDITIONAL_TAGS_CARDINALITY_LIMIT.Motivation
Allow Serverless Compatibility Layer to send additional metric tags on trace stats. See RFC.
https://datadoghq.atlassian.net/browse/SVLS-8787
Additional Notes
Dependent on these changes in libdatadog: DataDog/libdatadog#2170
Describe how to test/QA your changes
DD_TRACE_EXPERIMENTAL_FEATURES_ENABLEDDD_TAGS: custom.primary:val,workload:azure_functionsDD_TRACE_EXPERIMENTAL_FEATURES_ENABLED: trueDD_TRACE_STATS_ADDITIONAL_TAGS: custom.primary,workload