feat(trace-stats): add span-derived primary tags to SpanConcentrator#1858
Closed
lucaspimentel wants to merge 3 commits intomainfrom
Closed
feat(trace-stats): add span-derived primary tags to SpanConcentrator#1858lucaspimentel wants to merge 3 commits intomainfrom
SpanConcentrator#1858lucaspimentel wants to merge 3 commits intomainfrom
Conversation
…ntrator Add span_derived_primary_tags as a new aggregation dimension, allowing user-configured tag keys to be extracted from spans and used for stats aggregation. Unlike peer tags, these apply to all eligible spans regardless of span.kind. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
SpanConcentrator
🔒 Cargo Deny Results✅ No issues found! 📦
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1858 +/- ##
==========================================
+ Coverage 71.69% 71.81% +0.12%
==========================================
Files 429 429
Lines 67886 68163 +277
==========================================
+ Hits 48672 48954 +282
+ Misses 19214 19209 -5
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
Contributor
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
- Update from_span() doc to mention span_derived_primary_tag_keys - Replace em-dashes with colons in code comments - Add clarifying comment for missing "version" key on client span 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
lucaspimentel
added a commit
to DataDog/datadog-lambda-extension
that referenced
this pull request
Apr 9, 2026
Parse the env var and wire it through Config for use as additional APM stats aggregation dimensions. The actual SpanConcentrator call is gated on DataDog/libdatadog#1858. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
lucaspimentel
added a commit
to DataDog/datadog-lambda-extension
that referenced
this pull request
Apr 9, 2026
Parse the env var and wire it through Config for use as additional APM stats aggregation dimensions. The actual SpanConcentrator call is gated on DataDog/libdatadog#1858. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Member
Author
|
This was just a test. We already have #1815. Closing. |
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?
Adds
span_derived_primary_tagsas a new aggregation dimension inSpanConcentrator.User-configured tag keys (e.g.
aws.s3.bucket,datacenter,customer_tier) are extracted from spans and included in APM stats, enabling serverless customers who can't rely on container tags to use primary tags.This follows the existing peer tags pattern, but without
span.kindgating. Span-derived primary tags apply to all eligible spans (not justclient/producer/consumer).Stats computation scenarios
There are 3 scenarios where APM stats are computed or forwarded. This PR (plus the existing proto field) covers all of them:
from_span()extracts tags,encode_grouped_stats()serializes to proto/v0.6/statsand are forwarded as-is -- they never touchSpanConcentrator. Thespan_derived_primary_tagsfield passes through on the proto untouched.from_span()/add_span()path as scenario 1*Scenario 3 requires a follow-up bottlecap PR to parse
DD_APM_SPAN_DERIVED_PRIMARY_TAGSand callset_span_derived_primary_tag_keys()-- without that, the keys default to empty and no tags get extracted.Changes
libdd-trace-stats/src/span_concentrator/aggregation.rsspan_derived_primary_tagsfield toBorrowedAggregationKeyandOwnedAggregationKeyEquivalentimpl,Fromconversions, and hash/equality to include the new fieldfrom_span()to acceptspan_derived_primary_tag_keysand extract tags unconditionally from span metaencode_grouped_stats()to serialize tags as"key:value"strings (replacing thevec![] // Todostub)From<pb::ClientGroupedStats>to deserialize the field for re-aggregationlibdd-trace-stats/src/span_concentrator/mod.rsspan_derived_primary_tag_keys: Vec<String>field toSpanConcentratorset_span_derived_primary_tag_keys()setter (no constructor change)BorrowedAggregationKey::from_span()inadd_span()libdd-trace-stats/src/span_concentrator/tests.rstest_span_derived_primary_tags_aggregationintegration test covering:Motivation
Support for SVLS-8627. The agent-side implementation landed in DataDog/datadog-agent#42996. The proto field
span_derived_primary_tags(tag 22 onClientGroupedStats) already exists -- this PR wires it up in the stats computation layer.Additional Notes
SpanConcentrator::new()signature is unchanged -- keys are set via a setter, consistent with the existingset_peer_tags()/set_span_kinds()pattern.DD_APM_SPAN_DERIVED_PRIMARY_TAGSand call the new setter.How to test the change?
All 14 tests pass, including the new
test_span_derived_primary_tags_aggregation.🤖 Generated with Claude Code