[Tracer] Add optional tags to OTLP trace metrics - #9002
Conversation
BenchmarksBenchmark execution time: 2026-08-31 15:03:00 Comparing candidate commit bcaef7a in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 71 metrics, 0 unstable metrics, 72 known flaky benchmarks, 54 flaky benchmarks without significant changes.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9002) and master.
|
|||||||||||||||||||||||||||||||||||
| Metric | Master (Mean ± 95% CI) | Current (Mean ± 95% CI) | Change | Status |
|---|---|---|---|---|
| .NET Framework 4.8 - Baseline | ||||
| duration | 201.13 ± (201.15 - 202.03) ms | 215.92 ± (215.79 - 216.73) ms | +7.4% | ❌⬆️ |
| .NET Framework 4.8 - Bailout | ||||
| duration | 206.79 ± (206.24 - 207.27) ms | 220.00 ± (219.81 - 220.72) ms | +6.4% | ❌⬆️ |
| .NET Framework 4.8 - CallTarget+Inlining+NGEN | ||||
| duration | 1206.04 ± (1205.34 - 1212.01) ms | 1280.85 ± (1281.66 - 1288.56) ms | +6.2% | ❌⬆️ |
b2caa13 to
d0cd8d9
Compare
## Summary Aligns .NET OTLP trace metrics with the cross-tracer contract in DataDog/system-tests#7466. - Emits OTLP metric attributes independently of `DD_TRACE_OTEL_SEMANTICS_ENABLED` while retaining that setting for its other consumers. - Emits core SMC attributes first in the order `service.name`, `status.code`, `span.kind`, and `span.name`; unknown span kinds default to `SPAN_KIND_INTERNAL`. - Always emits `datadog.operation.name`, emits known trace-root and top-level values as booleans, and emits `datadog.svc_src` when present. Process and peer-tag arrays remain intentionally deferred to #9002. ## Validation - Focused `OtlpSpanStatsSerializerTests`: 59 passed - Production and test `dotnet format --verify-no-changes`: passed - `Datadog.Trace.csproj -f netstandard2.0 --no-restore`: passed with no warnings or errors - `git diff --check`: passed
5444ae8 to
d2c36d2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2c36d2512
ℹ️ 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".
| // TODO: Preserve the cardinality-limit sentinel once its OTLP representation is defined. | ||
| return Array.IndexOf(encodedTag, (byte)':'); |
There was a problem hiding this comment.
Preserve the cardinality-overflow dimension
When the additional-tag cardinality limiter folds a bucket, AdditionalMetricTags contains the separator-less tracer_blocked_value sentinel, so this returns -1 and both the JSON and protobuf loops omit the dimension entirely. If the same core dimensions also have spans with no configured additional tag, the normal and overflow buckets serialize with identical attributes, allowing the OTLP receiver to merge or discard one data point and corrupt the histogram totals; encode an explicit overflow attribute instead of dropping the sentinel.
Useful? React with 👍 / 👎.
|
With this change, the following tests pass (link): Although this PR adds support for serializing peer tags in OTLP, the value is not set in the aggregator. The corresponding system test continues to fail. This is expected. |
andrewlock
left a comment
There was a problem hiding this comment.
I think fundamentally the design here is not sound. We're doing huge allocations to try to decode utf8 byte arrays, but given we have access to those sources further up the pipeline, we should be looking at how we can expose these values instead
|
|
||
| private static int FindEncodedTagSeparator(byte[] encodedTag) | ||
| { | ||
| // TODO: Preserve the cardinality-limit sentinel once its OTLP representation is defined. |
There was a problem hiding this comment.
This seems like something we need to decide on/handle before we can merge this PR, otherwise you will be reporting incorrect stats? 🤔
| // TODO: Preserve the cardinality-limit sentinel once its OTLP representation is defined. | ||
| return Array.IndexOf(encodedTag, (byte)':'); |
Summary
datadog.process_tagsas a resource string arraydatadog.peer_tagsas a data-point string arrayThis keeps optional tag serialization separate from the core OTLP trace metrics implementation in #8992.
Test plan
OtlpSpanStatsSerializerTestspass on .NET 10