[Propagators] OTLP trace export carries ot.th/rv[APMAPI-2170] - #9062
[Propagators] OTLP trace export carries ot.th/rv[APMAPI-2170]#9062MilanGarnier wants to merge 3 commits into
ot.th/rv[APMAPI-2170]#9062Conversation
ot.th/rv (APMAPI-2170)
ot.th/rv (APMAPI-2170)ot.th/rv[APMAPI-2170]
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9062) and master. ✅ No regressions detected |
BenchmarksBenchmark execution time: 2026-08-21 09:34:59 Comparing candidate commit 4b6a5e8 in PR branch Found 0 performance improvements and 47 performance regressions! Performance is the same for 25 metrics, 0 unstable metrics, 110 known flaky benchmarks, 16 flaky benchmarks without significant changes.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf379941ce
ℹ️ 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".
| var otelTraceState = spanModel.Span.Context.OtelTraceState; | ||
| if (!StringUtil.IsNullOrEmpty(otelTraceState)) |
There was a problem hiding this comment.
Derive tracestate when OTLP export requires it
When OTLP export is enabled with a supported injection configuration that omits tracecontext (for example, DD_TRACE_PROPAGATION_STYLE_INJECT=datadog), locally rooted probability-sampled traces still have a null OtelTraceState: TraceContext.SetSamplingPriority() only derives rv/th when IsW3CTraceContextInjectionEnabled() is true. Consequently this new serializer branch emits no traceState, so the advertised OTLP sampling metadata disappears for that configuration. OTLP export itself needs to be treated as a consumer when deciding whether to derive the state.
Useful? React with 👍 / 👎.
2138077 to
4b6a5e8
Compare
| internal void WriteSpans(JsonTextWriter writer, in TraceChunkModel traceChunk, bool emitStartingComma) | ||
| { | ||
| var otelTraceState = traceChunk.SpanCount > 0 ? traceChunk.GetSpanModel(0).Span.Context.OtelTraceState : null; | ||
| var otlpTraceState = StringUtil.IsNullOrEmpty(otelTraceState) ? null : "ot=" + otelTraceState; |
There was a problem hiding this comment.
non-blocking: Is there a long-term plan to emit the entire tracestate field into the OTLP span rather than just the ot part? I suppose for efficiency reasons we only need to propagate the ot part for OTel probabilistic sampling to work but in the future this might be flagged as a missing feature if we don't do the whole tracestate
| internal void WriteSpan(JsonTextWriter writer, SpanModel spanModel) | ||
| { | ||
| var otelTraceState = spanModel.Span.Context.OtelTraceState; | ||
| var otlpTraceState = StringUtil.IsNullOrEmpty(otelTraceState) ? null : "ot=" + otelTraceState; | ||
| WriteSpan(writer, spanModel, otlpTraceState); | ||
| } | ||
|
|
||
| private void WriteSpan(JsonTextWriter writer, SpanModel spanModel, string? otlpTraceState) |
There was a problem hiding this comment.
Before merging, let's make sure to only have one WriteSpan method defined. Currently there is one that is only called in the product code (the 3-argument overload) and one that is only called in the test code (the 2-argument overload). If the otelTraceState already had the "ot=" prefix in the value, then the 2-argument overload would work, otherwise we should go with the 3-argument one.
| internal void WriteSpan(JsonTextWriter writer, SpanModel spanModel) | |
| { | |
| var otelTraceState = spanModel.Span.Context.OtelTraceState; | |
| var otlpTraceState = StringUtil.IsNullOrEmpty(otelTraceState) ? null : "ot=" + otelTraceState; | |
| WriteSpan(writer, spanModel, otlpTraceState); | |
| } | |
| private void WriteSpan(JsonTextWriter writer, SpanModel spanModel, string? otlpTraceState) | |
| internal void WriteSpan(JsonTextWriter writer, SpanModel spanModel, string? otlpTraceState = null) |
| result.Links.Should().BeNullOrEmpty(); | ||
| } | ||
|
|
||
| [Fact] |
There was a problem hiding this comment.
Why is this unit test being reverted?
zacharycmontoya
left a comment
There was a problem hiding this comment.
This set of changes LGTM
Summary of changes
Export the
ot=tracestate member in OTLP JSON and protobuf spans. (contains tracestate sampling datathandrv).Implementation details
Serialize the existing
OtelTraceStatevalue when present.Test coverage
Added focused JSON and protobuf serializer tests for present and absent values.
Other details
Stacked on #8983 which brings the support for otel tracestate sampling, and should be reviewed first.
System tests: TODO