feat: pass span_kinds_stats_computed and peer_tags to span concentrator#124
feat: pass span_kinds_stats_computed and peer_tags to span concentrator#124duncanpharvey wants to merge 8 commits intomainfrom
Conversation
674ae04 to
97a2f9e
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the serverless trace agent’s stats computation configuration by (1) ensuring specific span.kind values can trigger stats computation even when spans aren’t top-level/measured, and (2) including “peer tag” keys so computed stats can be enriched with additional peer-related dimensions.
Changes:
- Add a
peer_tagsconfiguration field derived from an embedded JSON mapping, and expose it via/info. - Pass
SPAN_KINDS_STATS_COMPUTEDand configuredpeer_tagsinto the span concentrator creation path. - Add integration + unit test coverage to validate
/infooutput and peer-tag/span-kind driven stats behavior.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/datadog-trace-agent/tests/integration_test.rs | Adds integration assertions for /info (span_kinds_stats_computed, peer_tags) and verifies peer tags + eligible span kinds affect computed stats. |
| crates/datadog-trace-agent/tests/common/helpers.rs | Adds helpers to generate span.kind/peer-tag traces and decode gzipped msgpack stats payloads in integration tests. |
| crates/datadog-trace-agent/src/trace_processor.rs | Updates test config construction to include the new peer_tags config field. |
| crates/datadog-trace-agent/src/stats_concentrator_service.rs | Introduces SPAN_KINDS_STATS_COMPUTED and wires span kinds + peer tags into SpanConcentrator::new during concentrator initialization. |
| crates/datadog-trace-agent/src/peer_tags.rs | New module to parse embedded mappings and produce a sorted/deduped peer tag key list, with unit tests. |
| crates/datadog-trace-agent/src/peer_tags_mappings.json | Embedded peer tag mappings source used to derive the peer tag key set. |
| crates/datadog-trace-agent/src/mini_agent.rs | Exposes span_kinds_stats_computed and peer_tags on /info, and passes peer tags into the handler. |
| crates/datadog-trace-agent/src/lib.rs | Exports the new peer_tags module. |
| crates/datadog-trace-agent/src/config.rs | Adds peer_tags to config and initializes it from the embedded mappings. |
| crates/datadog-trace-agent/Cargo.toml | Adds flate2 as a dev-dependency for gzip decoding in tests. |
| Cargo.lock | Updates lockfile to include flate2. |
| let concentrator = self | ||
| .concentrators | ||
| .entry(Arc::clone(&metadata)) | ||
| .or_insert_with(new_concentrator); | ||
| .or_insert_with(|| { | ||
| Self::new_span_concentrator(self.config.peer_tags.clone()) | ||
| }); |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09bd1877fe
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09bd1877fe
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { "name": "http.server_name", "provider": "datadog", "type": "string" }, | ||
| { "name": "out.host", "provider": "datadog", "type": "string" }, | ||
| { "name": "dns.hostname", "provider": "datadog", "type": "string" }, | ||
| { "name": "network.destination.ip", "provider": "otel", "type": "string" } |
There was a problem hiding this comment.
Avoid aggregating raw destination IP peer tags
When client/producer/consumer spans carry network.destination.ip, this new default key is passed into both the agent-side SpanConcentrator and /info for tracer-side stats. I checked the pinned libdd-trace-stats implementation at d7eef80: it copies configured peer tag values directly into ClientGroupedStats.peer_tags via format!("{k}:{v}") without IP quantization, so OTel spans that set destination IPs will create one stats aggregation group per raw remote IP and can explode stats cardinality/cost. Please omit this key until the concentrator quantizes IP peer tags, or add quantization before advertising/using it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
quantize_peer_ip_addresses is available in libdatadog but not yet applied to trace stats aggregation in libdd-trace-stats. Checking with libdatadog to see when this change can be applied.
There was a problem hiding this comment.
with tracer.trace("test_span") as span:
span.set_tag("span.kind", "client")
span.set_tag("peer.hostname", "127.0.0.1")
span.set_tag("_dd.flattened.peer.tags", "peer.hostname:127.0.0.1")
with tracer.trace("test_span") as span:
span.set_tag("span.kind", "client")
span.set_tag("peer.hostname", "192.0.2.1")
span.set_tag("_dd.flattened.peer.tags", "peer.hostname:192.0.2.1")
…1944) # What does this PR do? Quantize IP addresses for peer tags when aggregating trace stats. # Motivation Needed for agent side stats computation in the Serverless Compatibility Layer (used as the agent in Azure Functions) in DataDog/serverless-components#124. # Additional Notes Anything else we should know when reviewing? # How to test the change? Describe here in detail how the change can be validated. Co-authored-by: Eldolfin <oscar.ledauphin@datadoghq.com>
7818b4b to
0162d7f
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What does this PR do?
span_kinds_stats_computedandpeer_tagsto span concentrator.span_kinds_stats_computedandpeer_tagsin/infoendpoint response.Motivation
serverclientproducerconsumerhttps://datadoghq.atlassian.net/browse/SVLS-8977
Additional Notes
test_mini_agent_named_pipe_with_real_flushers. Now, when a shutdown signal arrives, each connection gets a chance to finish its current request before closing, rather than potentially being killed mid-response.Describe how to test/QA your changes
/infoendpoint contains expected values forspan_kinds_stats_computedandpeer_tagsserver)