Skip to content

Fix OTLP trace metrics attribute gaps in span stats serializer - #8992

Merged
mabdinur merged 21 commits into
masterfrom
munir/otlp-trace-metrics-fixes
Aug 13, 2026
Merged

Fix OTLP trace metrics attribute gaps in span stats serializer#8992
mabdinur merged 21 commits into
masterfrom
munir/otlp-trace-metrics-fixes

Conversation

@mabdinur

@mabdinur mabdinur commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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

- status.code: fix protobuf path to emit the OTel string literal
  (STATUS_CODE_OK/STATUS_CODE_ERROR) instead of an int enum, and make
  it unconditional in both JSON and protobuf paths (was previously
  omitted on non-error data points).
- is_trace_root: emit datadog.is_trace_root next to
  datadog.span.top_level, gated behind OTel-semantics suppression like
  other datadog.-prefixed attributes.
- additional_metric_tags: emit each configured key as its own
  unprefixed data-point attribute, never gated by OTel-semantics.
- span.kind: canonicalize to the uppercase OTel Span Metrics Connector
  convention (SPAN_KIND_SERVER, etc.) via a lookup table.
- process_tags/peer_tags: leave a TODO comment; not wired into OTLP
  output this round.

Companion system-tests PR: DataDog/system-tests#7363
@mabdinur mabdinur added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Aug 4, 2026
@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8992) and master.

✅ No regressions detected

📄 View the full report (charts + all metrics) →

@pr-commenter

pr-commenter Bot commented Aug 4, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-12 18:22:21

Comparing candidate commit d0cd8d9 in PR branch munir/otlp-trace-metrics-fixes with baseline commit 0aacbcb in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 2 performance regressions! Performance is the same for 70 metrics, 0 unstable metrics, 67 known flaky benchmarks, 59 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TracerBenchmark.StartSpan_SetActive net472

  • 🟥 throughput [-13250.361op/s; -10469.466op/s] or [-7.643%; -6.039%]

scenario:Benchmarks.Trace.HttpClientBenchmark.SendAsync net472

  • 🟥 throughput [-5394.265op/s; -5139.118op/s] or [-6.158%; -5.867%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-8296.062op/s; -7369.490op/s] or [-9.837%; -8.738%]

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1

  • 🟥 throughput [-10249.292op/s; -8953.017op/s] or [-10.421%; -9.103%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+311.221ms; +318.301ms] or [+154.439%; +157.952%]
  • 🟥 throughput [-43.400op/s; -39.434op/s] or [-7.808%; -7.095%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟥 execution_time [+382.785ms; +385.626ms] or [+302.424%; +304.668%]
  • 🟩 throughput [+85.057op/s; +89.727op/s] or [+11.214%; +11.830%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+400.012ms; +402.670ms] or [+353.995%; +356.348%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 allocated_mem [+4.693KB; +4.694KB] or [+98.806%; +98.821%]
  • 🟥 throughput [-61449.251op/s; -61090.073op/s] or [-47.811%; -47.531%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net6.0

  • 🟥 allocated_mem [+3.816KB; +3.816KB] or [+80.699%; +80.711%]
  • 🟩 execution_time [-15.902ms; -11.712ms] or [-7.427%; -5.470%]
  • 🟥 throughput [-59853.835op/s; -57084.708op/s] or [-43.690%; -41.669%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody netcoreapp3.1

  • 🟥 allocated_mem [+4.544KB; +4.544KB] or [+98.261%; +98.274%]
  • 🟥 throughput [-48924.774op/s; -46672.667op/s] or [-44.234%; -42.197%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net472

  • 🟥 allocated_mem [+1.315KB; +1.315KB] or [+106.388%; +106.404%]
  • 🟥 throughput [-269164.544op/s; -265702.992op/s] or [-27.483%; -27.130%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0

  • 🟥 allocated_mem [+479 bytes; +480 bytes] or [+39.212%; +39.221%]
  • 🟩 execution_time [-26.726ms; -21.869ms] or [-11.919%; -9.753%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 allocated_mem [+1.280KB; +1.280KB] or [+105.947%; +105.963%]
  • 🟥 throughput [-161623.576op/s; -145499.902op/s] or [-23.222%; -20.906%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472

  • 🟥 allocated_mem [+3.378KB; +3.378KB] or [+89.003%; +89.017%]
  • 🟥 throughput [-74050.995op/s; -73259.682op/s] or [-49.835%; -49.303%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0

  • 🟥 allocated_mem [+3.336KB; +3.336KB] or [+88.150%; +88.161%]
  • 🟥 throughput [-73513.676op/s; -70636.391op/s] or [-46.776%; -44.945%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody netcoreapp3.1

  • 🟥 allocated_mem [+3.264KB; +3.264KB] or [+88.493%; +88.506%]
  • 🟥 throughput [-55415.846op/s; -52803.256op/s] or [-44.146%; -42.065%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 throughput [+309291.620op/s; +326527.137op/s] or [+10.313%; +10.888%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟩 execution_time [-18.553ms; -14.179ms] or [-8.552%; -6.536%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net472

  • 🟩 allocated_mem [-13.759KB; -13.757KB] or [-42.326%; -42.318%]
  • 🟥 execution_time [+299.784ms; +300.395ms] or [+149.792%; +150.097%]
  • 🟩 throughput [+835.766op/s; +925.922op/s] or [+9.231%; +10.227%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟩 allocated_mem [-13.722KB; -13.718KB] or [-42.341%; -42.329%]
  • 🟥 execution_time [+299.676ms; +302.963ms] or [+151.128%; +152.785%]
  • 🟩 throughput [+2040.991op/s; +2361.033op/s] or [+15.611%; +18.058%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs netcoreapp3.1

  • 🟩 allocated_mem [-13.722KB; -13.718KB] or [-42.341%; -42.329%]
  • 🟥 execution_time [+300.536ms; +302.914ms] or [+151.387%; +152.584%]
  • 🟩 throughput [+1781.688op/s; +1913.113op/s] or [+17.201%; +18.470%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net472

  • 🟥 execution_time [+297.054ms; +298.379ms] or [+145.901%; +146.552%]
  • 🟩 throughput [+583.407op/s; +591.903op/s] or [+15.466%; +15.692%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+298.181ms; +300.297ms] or [+145.770%; +146.804%]
  • 🟩 throughput [+2784.402op/s; +2809.785op/s] or [+40.452%; +40.821%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+300.574ms; +301.388ms] or [+150.227%; +150.633%]
  • 🟩 throughput [+1386.384op/s; +1399.857op/s] or [+27.519%; +27.786%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472

  • 🟩 execution_time [-145.633µs; -141.267µs] or [-29.900%; -29.004%]
  • 🟩 throughput [+842.973op/s; +872.881op/s] or [+41.057%; +42.513%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0

  • 🟩 execution_time [-135.781µs; -109.026µs] or [-31.141%; -25.005%]
  • 🟩 throughput [+827.628op/s; +951.889op/s] or [+35.982%; +41.384%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1

  • 🟩 execution_time [-141.754µs; -119.670µs] or [-30.371%; -25.640%]
  • 🟩 throughput [+768.195op/s; +852.652op/s] or [+35.461%; +39.360%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472

  • 🟩 execution_time [-128.552µs; -124.352µs] or [-34.708%; -33.574%]
  • 🟩 throughput [+1376.578op/s; +1425.166op/s] or [+50.982%; +52.782%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net6.0

  • 🟩 execution_time [-102.730µs; -79.097µs] or [-32.796%; -25.251%]
  • 🟩 throughput [+1189.976op/s; +1393.359op/s] or [+37.095%; +43.435%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1

  • 🟩 execution_time [-138.634µs; -116.246µs] or [-37.925%; -31.800%]
  • 🟩 throughput [+1345.516op/s; +1482.452op/s] or [+48.285%; +53.199%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.949ms; +300.704ms] or [+149.705%; +150.082%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • 🟥 execution_time [+411.635ms; +420.614ms] or [+447.258%; +457.014%]
  • 🟩 throughput [+1018.856op/s; +1236.935op/s] or [+8.372%; +10.164%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1

  • unstable execution_time [+297.751ms; +350.078ms] or [+226.079%; +265.811%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+333.997ms; +401.225ms] or [+153.569%; +184.479%]
  • 🟥 throughput [-555.002op/s; -501.616op/s] or [-50.289%; -45.451%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • unstable execution_time [+207.125ms; +340.398ms] or [+88.268%; +145.063%]
  • 🟥 throughput [-672.400op/s; -588.922op/s] or [-44.849%; -39.281%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+344.843ms; +352.124ms] or [+206.256%; +210.611%]
  • 🟥 throughput [-398.391op/s; -363.198op/s] or [-27.739%; -25.289%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1

  • unstable execution_time [-223.639µs; -29.527µs] or [-11.981%; -1.582%]
  • unstable throughput [+20.634op/s; +146.078op/s] or [+3.851%; +27.266%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0

  • 🟩 execution_time [-140.887µs; -111.439µs] or [-7.137%; -5.645%]
  • 🟩 throughput [+31.153op/s; +38.782op/s] or [+6.150%; +7.656%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+302.275ms; +303.656ms] or [+152.220%; +152.915%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net6.0

  • 🟥 execution_time [+300.600ms; +302.001ms] or [+150.631%; +151.333%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch netcoreapp3.1

  • 🟥 execution_time [+300.863ms; +304.322ms] or [+151.141%; +152.878%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+302.730ms; +304.395ms] or [+152.021%; +152.857%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net6.0

  • 🟥 execution_time [+298.882ms; +301.474ms] or [+147.784%; +149.065%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟥 execution_time [+303.501ms; +307.287ms] or [+153.828%; +155.746%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+299.350ms; +301.984ms] or [+150.247%; +151.569%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net6.0

  • 🟥 execution_time [+297.143ms; +300.659ms] or [+148.099%; +149.851%]
  • 🟩 throughput [+49568.256op/s; +54627.197op/s] or [+9.843%; +10.847%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync netcoreapp3.1

  • 🟥 execution_time [+299.080ms; +301.846ms] or [+148.790%; +150.166%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0

  • 🟩 execution_time [-16.496ms; -12.818ms] or [-7.671%; -5.960%]
  • 🟩 throughput [+18392.964op/s; +25180.063op/s] or [+5.046%; +6.908%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472

  • unstable execution_time [+15.274µs; +60.892µs] or [+3.773%; +15.041%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟩 allocated_mem [-26.568KB; -26.546KB] or [-9.691%; -9.683%]
  • unstable execution_time [-30.327µs; +28.166µs] or [-5.994%; +5.567%]
  • unstable throughput [-99.223op/s; +109.265op/s] or [-4.951%; +5.452%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark netcoreapp3.1

  • unstable execution_time [-46.271µs; +14.714µs] or [-8.018%; +2.550%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • unstable execution_time [+6.664µs; +10.963µs] or [+15.751%; +25.913%]
  • 🟥 throughput [-4967.941op/s; -3162.794op/s] or [-20.913%; -13.314%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark netcoreapp3.1

  • unstable execution_time [-13.679µs; -5.723µs] or [-21.223%; -8.878%]
  • unstable throughput [+1411.353op/s; +3156.098op/s] or [+8.659%; +19.364%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+302.302ms; +303.919ms] or [+152.800%; +153.617%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+301.858ms; +304.433ms] or [+153.645%; +154.955%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+300.298ms; +303.555ms] or [+150.336%; +151.967%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0

  • 🟩 throughput [+41279.089op/s; +45802.172op/s] or [+7.813%; +8.669%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+299.407ms; +301.219ms] or [+149.228%; +150.130%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+299.818ms; +302.811ms] or [+150.554%; +152.057%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+303.143ms; +305.597ms] or [+153.734%; +154.979%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+299.437ms; +300.321ms] or [+149.361%; +149.802%]
  • 🟩 throughput [+66001906.532op/s; +66376485.984op/s] or [+48.067%; +48.339%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+421.027ms; +426.839ms] or [+523.622%; +530.850%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟥 execution_time [+298.447ms; +299.609ms] or [+148.858%; +149.438%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟩 throughput [+100591.936op/s; +108926.512op/s] or [+9.392%; +10.170%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟩 throughput [+48225.938op/s; +67497.513op/s] or [+5.582%; +7.813%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net6.0

  • 🟩 throughput [+86630.380op/s; +118609.468op/s] or [+6.705%; +9.181%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan netcoreapp3.1

  • 🟩 throughput [+79458.957op/s; +87658.377op/s] or [+7.892%; +8.706%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net6.0

  • 🟩 throughput [+56815.079op/s; +61533.544op/s] or [+10.317%; +11.173%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1

  • 🟩 throughput [+22642.261op/s; +32256.355op/s] or [+5.068%; +7.220%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

Previously omitted when it matched the resource-level default,
inconsistent with status.code and other data-point attributes
which are always present.
@mabdinur
mabdinur marked this pull request as ready for review August 5, 2026 19:50
@mabdinur
mabdinur requested a review from a team as a code owner August 5, 2026 19:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9586cb676b

ℹ️ 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".

Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated
@gh-worker-ownership-write-b05516
gh-worker-ownership-write-b05516 Bot removed the request for review from a team August 7, 2026 15:00
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated
Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated

private static bool TrySplitEncodedTag(byte[] encodedTag, out string key, out string value)
{
var decoded = EncodingHelpers.Utf8NoBom.GetString(encodedTag);

@zacharycmontoya zacharycmontoya Aug 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man we lose a lot of performance by having to do a UTF8 decode on the bytes we worked so hard to optimize 😞

@andrewlock do you think we could store StatsBucket.AdditionalMetricTags as a List<Tuple<byte[],byte[]>> so that we can store the key and value separately, each as UTF-8 bytes? That would allow us to write additional metrics in our stats payload as <key_bytes><colon_bytes><value_bytes> and in OTLP as KeyValue: key=<key_bytes>, value=StringValue: string_value=<value_bytes>.

Since this OTLP trace metrics feature is opt-in, perhaps we can do this in a follow-up, but the performance profile of additional metrics tags will be bad until we make further changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this to draft PR #9002 so we can optimize it separately

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Urgh, yeah, we definitely shouldn't be doing the decode, as that completely defeats the purpose of the optimisation 😅

I'm also not sure if splitting by Tuple<byte[],byte[]> quite works, as it depends on the APIs - we might end up needing to allocate the full array 🤔

Another potential approach would be something like this (not saying exactly this, depends on the APIs, I haven't checked 😅)

public class Utf8EncodedTag(byte[] fullBytes, int keyLength, int valueLength)
{
    private readonly byte[] _fullBytes = fullBytes;
    private readonly int _keyLength = keyLength;
    private readonly int _valueLength = valueLength;

    public ReadOnlySpan<byte> KeyAsSpan() => _fullBytes.AsSpan(0, _keyLength);
    public ReadOnlySpan<byte> ValueAsSpan() => _fullBytes.AsSpan(_fullBytes.Length - _valueLength - 1, _valueLength);
}

Anyway, we can explore in the other PR given this is removed here 🙂

Comment thread tracer/test/Datadog.Trace.Tests/Agent/OtlpSpanStatsSerializerTests.cs Outdated
Comment thread tracer/test/Datadog.Trace.Tests/Agent/OtlpSpanStatsSerializerTests.cs Outdated
@zacharycmontoya zacharycmontoya added docker_image_artifacts Use to label PRs for which you would need a Docker Image created for. and removed docker_image_artifacts Use to label PRs for which you would need a Docker Image created for. labels Aug 11, 2026

@zacharycmontoya zacharycmontoya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please get a 2nd approval (ideally from the .NET language platform team) before merging

@mabdinur
mabdinur enabled auto-merge (squash) August 12, 2026 03:03
@mabdinur
mabdinur disabled auto-merge August 12, 2026 03:03
@mabdinur
mabdinur requested review from a team and removed request for a team August 12, 2026 15:22
@mabdinur
mabdinur force-pushed the munir/otlp-trace-metrics-fixes branch from b2caa13 to d0cd8d9 Compare August 12, 2026 16:24

@andrewlock andrewlock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs
@mabdinur
mabdinur merged commit 9a60513 into master Aug 13, 2026
140 checks passed
@mabdinur
mabdinur deleted the munir/otlp-trace-metrics-fixes branch August 13, 2026 14:39
@github-actions github-actions Bot added this to the vNext-v3 milestone Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos area:opentelemetry OpenTelemetry support area:runtime-metrics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants