Skip to content

[OTLP] Add trace metrics via OTLP span metrics export#8826

Merged
mabdinur merged 37 commits into
masterfrom
munir/otlp-span-metrics
Jul 10, 2026
Merged

[OTLP] Add trace metrics via OTLP span metrics export#8826
mabdinur merged 37 commits into
masterfrom
munir/otlp-span-metrics

Conversation

@mabdinur

@mabdinur mabdinur commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

RFC: https://docs.google.com/document/d/1cDB_NVkyY_DXzb_EfQS6BsGu5Rx3gnf-tbpgJCYbIkc/edit?pli=1&tab=t.0

Overview

Adds the ability to export existing client-side computed stats via OTLP. No changes to cardinality, aggregation keys, or the values being exported — the same StatsBuffer/DDSketch data the tracer already computes is serialized as a traces.span.sdk.metrics.duration OTLP histogram (unit s, DELTA temporality) and POSTed to an OTLP metrics endpoint. This lets downstream collectors consume span metrics using OTel semantics without recomputing them from raw spans.

The PR is split into four commits — reviewing commit-by-commit is recommended.

Reviewer guide

Commit 1 — config keys (OTEL_TRACES_SPAN_METRICS_ENABLED, DD_TRACE_OTEL_SEMANTICS_ENABLED), StatsBucket min/max fields, TracerManagerFactory wiring. No serialization logic.

Commit 2OtlpSpanStatsSerializer.SerializeJson: projects DDSketch bins onto 16 fixed bounds via PositiveValueStore.EnumerateAscending(); exact min/max from StatsBucket since sketch values are approximate.

Commit 3 — same projection, hand-rolled protobuf encoding (no codegen). ApiOtlp.SendStatsAsyncImpl dispatches JSON vs protobuf via OTEL_EXPORTER_OTLP_METRICS_PROTOCOL.

Commit 4 — emits _dd.stats_computed OTLP resource attribute to prevent downstream Agent from recomputing stats (mirrors Datadog-Client-Computed-Stats header). Adds unit tests for OtlpSpanStatsSerializer.

Test coverage

System tests: DataDog/system-tests#6834

Notes

  • rpc.method attribute omitted (high cardinality, follow-up)

@github-actions github-actions Bot added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Jun 24, 2026
@mabdinur
mabdinur requested a review from link04 June 24, 2026 21:00
@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

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

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration70.29 ± (70.40 - 70.78) ms71.98 ± (71.85 - 72.35) ms+2.4%✅⬆️
.NET Framework 4.8 - Bailout
duration78.27 ± (78.04 - 78.62) ms74.60 ± (74.58 - 75.01) ms-4.7%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1082.14 ± (1081.42 - 1087.72) ms1078.15 ± (1077.79 - 1084.16) ms-0.4%
.NET Core 3.1 - Baseline
process.internal_duration_ms22.32 ± (22.27 - 22.37) ms22.31 ± (22.26 - 22.35) ms-0.1%
process.time_to_main_ms82.44 ± (82.12 - 82.75) ms82.33 ± (82.06 - 82.60) ms-0.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.92 ± (10.91 - 10.92) MB10.92 ± (10.92 - 10.93) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.20 ± (22.17 - 22.24) ms22.13 ± (22.10 - 22.16) ms-0.3%
process.time_to_main_ms83.18 ± (82.97 - 83.38) ms81.56 ± (81.42 - 81.70) ms-1.9%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.95 ± (10.95 - 10.96) MB10.96 ± (10.96 - 10.97) MB+0.1%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms208.92 ± (207.96 - 209.87) ms208.80 ± (207.75 - 209.85) ms-0.1%
process.time_to_main_ms528.42 ± (527.14 - 529.70) ms528.80 ± (527.63 - 529.98) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.26 ± (49.23 - 49.29) MB49.27 ± (49.23 - 49.30) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.3%
.NET 6 - Baseline
process.internal_duration_ms21.25 ± (21.20 - 21.31) ms21.17 ± (21.12 - 21.21) ms-0.4%
process.time_to_main_ms72.62 ± (72.36 - 72.88) ms72.26 ± (72.00 - 72.52) ms-0.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.63 ± (10.63 - 10.63) MB10.65 ± (10.65 - 10.65) MB+0.2%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.92 ± (20.89 - 20.96) ms20.85 ± (20.82 - 20.88) ms-0.4%
process.time_to_main_ms71.62 ± (71.44 - 71.80) ms71.49 ± (71.33 - 71.65) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.75 ± (10.74 - 10.75) MB10.76 ± (10.76 - 10.76) MB+0.2%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms372.93 ± (370.67 - 375.20) ms372.12 ± (370.10 - 374.15) ms-0.2%
process.time_to_main_ms536.23 ± (535.00 - 537.46) ms536.65 ± (535.40 - 537.91) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed50.26 ± (50.23 - 50.28) MB50.30 ± (50.28 - 50.32) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.2%
.NET 8 - Baseline
process.internal_duration_ms19.18 ± (19.15 - 19.20) ms19.15 ± (19.12 - 19.18) ms-0.1%
process.time_to_main_ms68.72 ± (68.59 - 68.85) ms68.71 ± (68.58 - 68.83) ms-0.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.67 ± (7.67 - 7.68) MB7.70 ± (7.69 - 7.70) MB+0.4%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.26 ± (19.22 - 19.31) ms19.32 ± (19.27 - 19.36) ms+0.3%✅⬆️
process.time_to_main_ms72.36 ± (72.08 - 72.63) ms72.35 ± (72.12 - 72.59) ms-0.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.73 ± (7.73 - 7.74) MB7.74 ± (7.73 - 7.75) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms298.86 ± (296.72 - 301.01) ms300.05 ± (297.93 - 302.17) ms+0.4%✅⬆️
process.time_to_main_ms484.53 ± (483.56 - 485.50) ms484.14 ± (483.19 - 485.09) ms-0.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed37.77 ± (37.74 - 37.80) MB37.82 ± (37.79 - 37.84) MB+0.1%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.3%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration202.96 ± (202.59 - 203.60) ms201.61 ± (201.67 - 202.60) ms-0.7%
.NET Framework 4.8 - Bailout
duration207.26 ± (206.64 - 207.60) ms205.22 ± (204.91 - 205.66) ms-1.0%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1222.14 ± (1219.03 - 1225.36) ms1211.42 ± (1210.55 - 1217.79) ms-0.9%
.NET Core 3.1 - Baseline
process.internal_duration_ms196.69 ± (196.25 - 197.13) ms194.53 ± (194.09 - 194.97) ms-1.1%
process.time_to_main_ms85.27 ± (84.94 - 85.61) ms84.47 ± (84.20 - 84.74) ms-0.9%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.06 ± (16.04 - 16.08) MB16.06 ± (16.03 - 16.08) MB-0.0%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (19 - 20)-1.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms195.55 ± (195.06 - 196.04) ms194.39 ± (194.05 - 194.72) ms-0.6%
process.time_to_main_ms86.42 ± (86.13 - 86.71) ms85.89 ± (85.69 - 86.09) ms-0.6%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.11 ± (16.09 - 16.13) MB16.12 ± (16.09 - 16.14) MB+0.1%✅⬆️
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)+0.1%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms386.78 ± (385.40 - 388.16) ms385.83 ± (384.41 - 387.24) ms-0.2%
process.time_to_main_ms545.82 ± (544.62 - 547.02) ms543.88 ± (542.80 - 544.96) ms-0.4%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.29 ± (58.09 - 58.50) MB58.01 ± (57.81 - 58.21) MB-0.5%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.0%
.NET 6 - Baseline
process.internal_duration_ms200.93 ± (200.46 - 201.40) ms201.18 ± (200.66 - 201.70) ms+0.1%✅⬆️
process.time_to_main_ms73.98 ± (73.72 - 74.24) ms74.55 ± (74.26 - 74.85) ms+0.8%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.33 ± (16.30 - 16.36) MB16.37 ± (16.34 - 16.39) MB+0.2%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.8%
.NET 6 - Bailout
process.internal_duration_ms199.45 ± (199.05 - 199.84) ms199.83 ± (199.39 - 200.27) ms+0.2%✅⬆️
process.time_to_main_ms74.88 ± (74.69 - 75.08) ms74.88 ± (74.58 - 75.17) ms-0.0%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.42 ± (16.39 - 16.44) MB16.44 ± (16.42 - 16.47) MB+0.2%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.5%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms584.19 ± (582.02 - 586.36) ms584.45 ± (581.99 - 586.92) ms+0.0%✅⬆️
process.time_to_main_ms553.00 ± (551.83 - 554.17) ms549.73 ± (548.66 - 550.81) ms-0.6%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed61.30 ± (61.23 - 61.37) MB61.62 ± (61.52 - 61.71) MB+0.5%✅⬆️
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms199.07 ± (198.62 - 199.52) ms197.39 ± (197.02 - 197.77) ms-0.8%
process.time_to_main_ms73.61 ± (73.33 - 73.89) ms73.17 ± (72.91 - 73.43) ms-0.6%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.73 ± (11.71 - 11.75) MB11.77 ± (11.75 - 11.79) MB+0.4%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)-0.4%
.NET 8 - Bailout
process.internal_duration_ms198.45 ± (197.95 - 198.95) ms196.66 ± (196.34 - 196.98) ms-0.9%
process.time_to_main_ms74.31 ± (74.06 - 74.56) ms74.00 ± (73.84 - 74.17) ms-0.4%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.73 ± (11.72 - 11.75) MB11.83 ± (11.81 - 11.85) MB+0.8%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.0%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms513.40 ± (510.24 - 516.56) ms510.85 ± (508.37 - 513.33) ms-0.5%
process.time_to_main_ms504.82 ± (503.89 - 505.74) ms499.69 ± (498.95 - 500.43) ms-1.0%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed51.13 ± (51.10 - 51.17) MB51.22 ± (51.19 - 51.26) MB+0.2%✅⬆️
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.0%
Comparison explanation

Execution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (72ms)  : 68, 76
    master - mean (71ms)  : 68, 73

    section Bailout
    This PR (8826) - mean (75ms)  : 71, 78
    master - mean (78ms)  : 74, 83

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,081ms)  : 1035, 1127
    master - mean (1,085ms)  : 1039, 1131

Loading
FakeDbCommand (.NET Core 3.1)
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (112ms)  : 105, 119
    master - mean (112ms)  : 105, 119

    section Bailout
    This PR (8826) - mean (110ms)  : 108, 112
    master - mean (113ms)  : 108, 117

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (774ms)  : 752, 795
    master - mean (774ms)  : 751, 797

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (100ms)  : 95, 105
    master - mean (101ms)  : 95, 106

    section Bailout
    This PR (8826) - mean (99ms)  : 94, 103
    master - mean (99ms)  : 94, 103

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (941ms)  : 901, 980
    master - mean (939ms)  : 894, 985

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (94ms)  : 92, 97
    master - mean (95ms)  : 92, 97

    section Bailout
    This PR (8826) - mean (99ms)  : 94, 104
    master - mean (99ms)  : 94, 104

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (814ms)  : 780, 848
    master - mean (814ms)  : 775, 853

Loading
HttpMessageHandler (.NET Framework 4.8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (202ms)  : 197, 207
    master - mean (203ms)  : 196, 210

    section Bailout
    This PR (8826) - mean (205ms)  : 201, 209
    master - mean (207ms)  : 202, 212

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,214ms)  : 1160, 1268
    master - mean (1,222ms)  : 1177, 1268

Loading
HttpMessageHandler (.NET Core 3.1)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (289ms)  : 282, 296
    master - mean (291ms)  : 284, 299

    section Bailout
    This PR (8826) - mean (290ms)  : 286, 295
    master - mean (292ms)  : 283, 301

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (972ms)  : 947, 997
    master - mean (977ms)  : 947, 1007

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (286ms)  : 280, 291
    master - mean (285ms)  : 278, 291

    section Bailout
    This PR (8826) - mean (284ms)  : 277, 291
    master - mean (284ms)  : 278, 290

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,166ms)  : 1134, 1199
    master - mean (1,172ms)  : 1134, 1209

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (282ms)  : 276, 287
    master - mean (283ms)  : 276, 290

    section Bailout
    This PR (8826) - mean (281ms)  : 276, 285
    master - mean (283ms)  : 276, 290

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,044ms)  : 1006, 1081
    master - mean (1,051ms)  : 1002, 1101

Loading

@pr-commenter

pr-commenter Bot commented Jun 25, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-09 14:57:11

Comparing candidate commit ebd7efd in PR branch munir/otlp-span-metrics with baseline commit d56c0bd in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 72 metrics, 0 unstable metrics, 60 known flaky benchmarks, 66 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 ----------------------------------'

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 [-8663.645op/s; -7905.206op/s] or [-10.273%; -9.373%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+324.813ms; +326.860ms] or [+161.184%; +162.200%]
  • 🟥 throughput [-41.917op/s; -38.094op/s] or [-7.542%; -6.854%]

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

  • 🟥 execution_time [+380.513ms; +382.482ms] or [+300.629%; +302.184%]
  • 🟩 throughput [+82.364op/s; +88.673op/s] or [+10.859%; +11.691%]

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

  • 🟥 execution_time [+393.399ms; +395.798ms] or [+348.143%; +350.266%]

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

  • 🟥 allocated_mem [+1.308KB; +1.308KB] or [+27.528%; +27.540%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+9.976%; +9.987%]
  • 🟩 execution_time [-16.157ms; -11.983ms] or [-7.546%; -5.596%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+27.500%; +27.510%]

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

  • 🟥 allocated_mem [+1.307KB; +1.307KB] or [+105.743%; +105.758%]
  • 🟥 throughput [-289274.493op/s; -285468.547op/s] or [-29.536%; -29.148%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.557%; +38.566%]
  • 🟩 execution_time [-26.749ms; -21.829ms] or [-11.929%; -9.735%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.288%; +105.304%]
  • 🟥 throughput [-149808.956op/s; -134010.581op/s] or [-21.525%; -19.255%]

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

  • 🟩 throughput [+7987.683op/s; +11022.242op/s] or [+5.082%; +7.013%]

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

  • 🟩 throughput [+10809.635op/s; +13471.477op/s] or [+8.611%; +10.732%]

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

  • 🟩 throughput [+478834.437op/s; +503680.266op/s] or [+15.966%; +16.795%]

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

  • 🟩 execution_time [-19.300ms; -14.967ms] or [-8.896%; -6.899%]
  • 🟩 throughput [+142647.214op/s; +197260.910op/s] or [+5.662%; +7.830%]

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

  • 🟥 execution_time [+299.790ms; +300.555ms] or [+149.795%; +150.177%]

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

  • 🟥 execution_time [+299.700ms; +302.993ms] or [+151.140%; +152.800%]

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

  • 🟥 execution_time [+299.799ms; +303.756ms] or [+151.016%; +153.009%]

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

  • 🟥 execution_time [+296.328ms; +297.241ms] or [+145.545%; +145.993%]

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

  • 🟥 execution_time [+294.019ms; +296.084ms] or [+143.735%; +144.745%]

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

  • 🟥 execution_time [+301.346ms; +302.862ms] or [+150.612%; +151.370%]

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

  • 🟥 execution_time [+27.701µs; +64.241µs] or [+6.353%; +14.734%]
  • 🟥 throughput [-284.534op/s; -138.301op/s] or [-12.370%; -6.013%]

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

  • 🟥 execution_time [+21.206µs; +44.800µs] or [+6.770%; +14.302%]
  • 🟥 throughput [-418.717op/s; -220.155op/s] or [-13.053%; -6.863%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.633ms; +300.446ms] or [+149.547%; +149.953%]

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

  • 🟥 execution_time [+419.436ms; +425.556ms] or [+455.735%; +462.384%]
  • 🟩 throughput [+747.285op/s; +919.377op/s] or [+6.141%; +7.555%]

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

  • unstable execution_time [+232.757ms; +302.691ms] or [+176.730%; +229.830%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+279.478ms; +315.407ms] or [+128.501%; +145.021%]
  • 🟥 throughput [-569.173op/s; -512.260op/s] or [-51.573%; -46.416%]

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

  • unstable execution_time [+150.844ms; +297.482ms] or [+64.284%; +126.774%]
  • 🟥 throughput [-676.046op/s; -592.495op/s] or [-45.092%; -39.520%]

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

  • 🟥 execution_time [+343.503ms; +354.783ms] or [+205.455%; +212.201%]
  • 🟥 throughput [-413.861op/s; -374.207op/s] or [-28.817%; -26.056%]

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

  • unstable throughput [+21.805op/s; +67.493op/s] or [+6.268%; +19.401%]

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

  • 🟩 execution_time [-153.916µs; -99.914µs] or [-7.797%; -5.061%]
  • 🟩 throughput [+28.833op/s; +43.494op/s] or [+5.692%; +8.586%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+303.520ms; +305.529ms] or [+152.847%; +153.859%]

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

  • 🟥 execution_time [+301.601ms; +304.529ms] or [+151.133%; +152.600%]

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

  • 🟥 execution_time [+301.100ms; +304.588ms] or [+151.260%; +153.012%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+303.358ms; +306.433ms] or [+152.336%; +153.881%]

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

  • 🟥 execution_time [+298.649ms; +300.543ms] or [+147.669%; +148.605%]

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

  • 🟥 execution_time [+301.380ms; +305.299ms] or [+152.752%; +154.739%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+281.594ms; +296.354ms] or [+141.335%; +148.743%]

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

  • 🟥 execution_time [+300.212ms; +303.370ms] or [+149.628%; +151.202%]
  • 🟩 throughput [+43259.241op/s; +50635.942op/s] or [+8.590%; +10.055%]

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

  • 🟥 execution_time [+304.370ms; +315.662ms] or [+151.422%; +157.039%]

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

  • 🟩 execution_time [-16.272ms; -12.630ms] or [-7.567%; -5.873%]

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

  • unstable execution_time [+14.835µs; +57.336µs] or [+3.664%; +14.162%]

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

  • 🟩 allocated_mem [-20.162KB; -20.139KB] or [-7.355%; -7.346%]
  • unstable execution_time [-34.090µs; +24.941µs] or [-6.738%; +4.929%]
  • unstable throughput [-84.393op/s; +123.844op/s] or [-4.211%; +6.180%]

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

  • 🟩 allocated_mem [-18.054KB; -18.036KB] or [-6.581%; -6.575%]
  • unstable execution_time [-59.255µs; +4.554µs] or [-10.269%; +0.789%]
  • unstable throughput [+4.203op/s; +183.475op/s] or [+0.240%; +10.482%]

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

  • unstable execution_time [+7.509µs; +12.302µs] or [+17.748%; +29.078%]
  • 🟥 throughput [-5354.664op/s; -3425.965op/s] or [-22.541%; -14.422%]

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

  • unstable execution_time [-13.356µs; -5.446µs] or [-20.722%; -8.449%]
  • unstable throughput [+1303.698op/s; +3051.408op/s] or [+7.999%; +18.721%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+302.702ms; +304.205ms] or [+153.002%; +153.762%]

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

  • 🟥 execution_time [+302.862ms; +305.204ms] or [+154.156%; +155.348%]

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

  • 🟥 execution_time [+298.392ms; +300.801ms] or [+149.382%; +150.588%]

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

  • 🟩 throughput [+35465.686op/s; +42493.918op/s] or [+6.713%; +8.043%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+298.516ms; +300.475ms] or [+148.783%; +149.760%]

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

  • 🟥 execution_time [+298.584ms; +312.842ms] or [+149.935%; +157.094%]

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

  • 🟥 execution_time [+303.389ms; +306.083ms] or [+153.859%; +155.226%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+301.152ms; +302.041ms] or [+150.216%; +150.660%]
  • 🟩 throughput [+60812235.762op/s; +61136040.242op/s] or [+44.287%; +44.523%]

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

  • 🟥 execution_time [+418.658ms; +424.334ms] or [+520.676%; +527.735%]

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

  • 🟥 execution_time [+299.446ms; +300.540ms] or [+149.357%; +149.902%]
  • 🟩 throughput [+17999281.158op/s; +18968149.587op/s] or [+7.973%; +8.402%]

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

  • 🟩 throughput [+69368.053op/s; +84853.805op/s] or [+6.477%; +7.923%]

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

  • 🟩 throughput [+82597.486op/s; +91754.518op/s] or [+8.203%; +9.113%]

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

  • 🟩 throughput [+52795.725op/s; +57184.557op/s] or [+9.587%; +10.384%]

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

  • 🟩 throughput [+26001.281op/s; +36034.351op/s] or [+5.820%; +8.066%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟩 throughput [+71607.223op/s; +89480.271op/s] or [+8.000%; +9.997%]

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.ActivityBenchmark.StartStopWithChild netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1
  • 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.StartFinishScope netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net6.0
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

@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: 00915b660f

ℹ️ 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/TracerManagerFactory.cs Outdated
Comment thread tracer/src/Datadog.Trace/Agent/ApiOtlp.cs
Comment thread tracer/src/Datadog.Trace/OpenTelemetry/OtlpMapper.cs
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/TracerManagerFactory.cs
Comment thread tracer/src/Datadog.Trace/Agent/StatsAggregator.cs Outdated
@mabdinur
mabdinur force-pushed the munir/otlp-span-metrics branch from 00915b6 to 74cd1de Compare June 26, 2026 14:55
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs
mabdinur and others added 11 commits July 1, 2026 19:10
Add OTEL_TRACES_SPAN_METRICS_ENABLED (tri-state gate) and DD_TRACE_OTEL_SEMANTICS_ENABLED
config keys. Extend StatsBucket with exact MinDuration/MaxDuration for OTLP histogram
min/max fields (DDSketch approximation is insufficient). Wire TracerManagerFactory to
create an OTLP-backed StatsAggregator when span metrics are enabled.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…duration)

Introduces OtlpSpanStatsSerializer with SerializeJson: converts a StatsBuffer into an
OTLP ExportMetricsServiceRequest (proto3 JSON). Projects DDSketch bins onto 16 fixed
explicit bounds (seconds). Uint64 fields (timestamps, counts) are encoded as quoted
strings per the proto3 JSON spec. Attribute set per data point: span.name, span.kind,
http.request.method, http.response.status_code, http.route, rpc.response.status_code,
status.code (errors only), service.name (when non-default). Datadog-specific attributes
(datadog.operation.name, datadog.span.type, etc.) suppressed when DD_TRACE_OTEL_SEMANTICS_ENABLED.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Extends OtlpSpanStatsSerializer with a binary-protobuf path (Serialize): hand-rolls
varint/fixed64/length-delimited encoding against the OTLP proto schema — no proto
codegen dependency. Adds attribute helpers (WriteAttribute, WriteIntAttribute,
WriteBoolAttribute) and FieldNumbers/AnyValueFieldNumbers constants.

Wires ApiOtlp.SendStatsAsyncImpl to serialize and POST to the OTLP metrics endpoint.
Protocol selected by OTEL_EXPORTER_OTLP_METRICS_PROTOCOL (http/protobuf default,
http/json for JSON). Custom headers from OTEL_EXPORTER_OTLP_METRICS_HEADERS applied
per request.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Mirror the Datadog-Client-Computed-Stats header (AgentWriter.CanComputeStats)
on the OTLP trace path so a downstream Datadog Agent does not recompute stats.

Co-authored-by: Cursor <[email protected]>
- Add #nullable enable (CS8632)
- Move const before readonly field (SA1203)
- Move private CreateBuffer/CreateKey methods after public [Fact] methods (SA1202)
- Put each StatsAggregationKey constructor arg on its own line (SA1117)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Add OTEL_TRACES_SPAN_METRICS_ENABLED and DD_TRACE_OTEL_SEMANTICS_ENABLED
to config_norm_rules.json so AllConfigurationValuesAreRegisteredWithIntake passes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
optional uint64 count and repeated uint64 bucket_counts are varint fields
(wire type 0) in the OTLP HistogramDataPoint proto — not fixed64 (wire type 1).
Using WireTypeFixed64 produced tag bytes 33/49 instead of 32/48, causing
conforming decoders to treat them as unknown fields and drop them.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Change 1: rpc.response.status_code emitted as canonical string name
  - Add GrpcStatusNames[0..16] lookup table
  - Add NormalizeGrpcStatusName: handles numeric codes, named codes,
    StatusCode.* prefix, CANCELED alias, NOTFOUND alias
  - Omit attribute when empty/unparseable/out-of-range

Change 2: rpc.method explicitly not emitted (remove TODO comment)
  - gRPC method is already the span resource/span.name; separate dimension
    would inflate cardinality for no benefit

Change 3: confirm true top-level counts (already implemented)
  - OTLP aggregation key already uses span.IsTopLevel, so top-level and
    non-top-level spans with identical other attributes bucket separately
  - Remove misleading "derived as all-spans-top-level" comment

Add tests covering all three changes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@mabdinur
mabdinur force-pushed the munir/otlp-span-metrics branch from a183e87 to bb159a5 Compare July 1, 2026 23:15
mabdinur and others added 5 commits July 1, 2026 19:25
…ndant comments

Decorative ── section headers were unique to OtlpSpanStatsSerializer — not used
elsewhere in the codebase. Multi-line XML docstrings on public methods and the
EncodeKeyValue helper explain what the code does, which is already clear from
names and signatures. Per-attribute comments in SerializeDataPoint duplicated
the string literals they sat above.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The metrics request factory was previously built from OtlpTransportStrategy.GetTraces,
which uses traces transport config (endpoint, protocol, headers, timeout). Add
GetMetrics() so the metrics factory respects OTEL_EXPORTER_OTLP_METRICS_* settings,
and stop manually adding metrics headers per-request since they're now DefaultHeaders
on the HttpClient.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
StatsBucket, StatsBuffer, and StatsAggregationKey constructors gained new
required parameters in master; update test call sites to match.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs
Comment thread tracer/src/Datadog.Trace/Agent/StatsAggregator.cs
Comment thread tracer/src/Datadog.Trace/Agent/StatsBucket.cs Outdated
}
}

public static byte[]? Serialize(StatsBuffer buffer, long bucketDurationNs, bool otelSemanticsEnabled)

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.

TODO for us dd-trace-dotnet maintainers: We should pass a Stream into here, rather than this method creating its own stream and allocating a byte[] as the return value

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.

This pattern should also be updated in OtlpMetricsSerializer.cs where this pattern was introduced

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.

Also, as a follow-up, the protobuf serialization should use the same logic as the JSON serialization so we can easily keep the two in-sync

Comment thread tracer/src/Datadog.Trace/Util/TimeHelpers.cs Outdated

@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.

Once the sub-second precision is restored (and assuming the system-tests for this feature pass), I think this can be approved. Please ping me when that's ready

…ds; MinDuration/MaxDuration as long

- NanosecondsToSeconds now divides by 1_000_000_000.0 (double) to
  preserve sub-second precision instead of truncating via integer division
- MinDuration/MaxDuration changed from double to long in StatsBucket,
  matching Duration; sentinel changed from double.MaxValue to long.MaxValue
- Remove now-unnecessary casts in OtlpSpanStatsSerializer
- Update TimeUtilsTests to assert sub-second precision
- Update SerializeJson_MinMaxWritten_WhenSet to use 1ms/50ms values

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@mabdinur

mabdinur commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Sub-second precision restored in 28a3656. Ready for another look @zacharycmontoya!


var api = new ManagedApi(settings.Manager, statsd, updateSampleRates, updateConfigHash, settings.PartialFlushEnabled);

if (settings.OtelTracesSpanMetricsEnabled)

@zacharycmontoya zacharycmontoya Jul 7, 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.

This block supports sending traces via MsgPack and also sending OTLP span metrics. Is this a supported scenario? If we're only supporting OTLP span metrics when exporting traces as OTLP then we don't need this block as it's covered in the first block

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.

This block handles OTEL_TRACES_SPAN_METRICS_ENABLED=true with MsgPack traces. We kept it because it simplifies testing and reproducibility — setting the env var to true always does what you'd expect regardless of trace encoding. Happy to remove it if you'd prefer to tie span metrics strictly to OTLP traces.

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.

in this case, should we merge it with the first block with a

if ((settings.Manager.InitialExporterSettings.TracesEncoding is TracesEncoding.OtlpProtobuf or TracesEncoding.OtlpJson)
    || settings.OtelTracesSpanMetricsEnabled)

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.

Actually the proposed approach is correct:

  • var api = new ManagedApi() ensures that we send DD traces
  • var otlpSpanMetricsAggregator = StatsAggregator.Create(otlpMetricsApi, ...) ensures we generate OTLP trace metrics

Merging with the first block would unconditionally send OTLP traces, so we wouldn't be able to send DD traces

@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! I have a couple of comments so please take a look at those before merging. Also please wait for a 2nd approval before merging, thanks!


for (int i = 1; i < BoundsNs.Length; i++)
{
if (valueNs < BoundsNs[i])

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.

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.

Fixed in a127a0c — both comparisons in FindBucketIndex now use <=.

When unset, auto-enables iff OTEL_TRACES_EXPORTER=otlp and DD_METRICS_OTEL_ENABLED=true.
When true, always enables span metrics export regardless of other settings.
When false, always disables span metrics export.
DD_TRACE_OTEL_SEMANTICS_ENABLED:

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.

NIT: could we keep the alphabetical order here

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.

Fixed in a127a0c — moved OTEL_TRACES_SPAN_METRICS_ENABLED to after OTEL_TRACES_SAMPLER_ARG and DD_TRACE_OTEL_SEMANTICS_ENABLED to its correct position near DD_TRACE_OTEL_ENABLED.

counts[0] += (ulong)Math.Round(sketch.ZeroCount);
}

foreach (var bin in sketch.PositiveValueStore.EnumerateAscending())

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.

NegativeValueStore is never read, maybe it will never happen, but maybe we could have some clock issue edge cases that we could log somehow?

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.

Added a debug log in ProjectSketch when NegativeValueStore is non-empty (a127a0c). Clock skew edge cases will now surface in logs.

mabdinur and others added 2 commits July 8, 2026 12:37
…s; sort YAML; log negative durations

- Restore GetWeight and weighted Hits/Errors/Duration/TopLevelHits in
  StatsAggregator; only MinDuration/MaxDuration tracking is new
- Revert StatsBucket Hits/Errors/Duration/TopLevelHits back to double
  (accumulate fractional sampling weights); MinDuration/MaxDuration stay long
- Fix FindBucketIndex to use <= per OTel inclusive upper-bound spec
- Add debug log in ProjectSketch when NegativeValueStore is non-empty
- Move OTEL_TRACES_SPAN_METRICS_ENABLED and DD_TRACE_OTEL_SEMANTICS_ENABLED
  to correct alphabetical positions in supported-configurations.yaml

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Move GetWeight above ConvertTimestamp XML doc (SA1612)
- Cast double Hits/Errors/Duration/TopLevelHits to long for WriteInt64 in StatsBuffer
- Use GetTotalCount() instead of TotalCount on vendored Store

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@mabdinur

mabdinur commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Fixed build errors in 68a5950:

  • SA1612: GetWeight was accidentally inserted between the XML doc and ConvertTimestamp, displacing the <param name="ns"> — moved above the doc block
  • CS1503: WriteInt64 in StatsBuffer can't accept double — added (long) casts on Hits/Errors/Duration/TopLevelHits
  • CS1061: vendored Store exposes GetTotalCount() not a TotalCount property — updated the negative-store check

@mabdinur
mabdinur requested a review from anna-git July 8, 2026 20:37

@link04 link04 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.

One last comment I got from the AI after having it look into related stats PRs and recent OTLP metrics changes was performance, for the OtlpSpanStatsSerializer.cs class serialize methods(general, e.g. lines 374-602), it found that:

Nit: lots of small buffer allocations in the serializer

This file allocates a new MemoryStream + BinaryWriter for nearly every field it writes — protobuf needs a field's byte length before writing it, so the pattern here is: write to a temp buffer, measure it, then copy into the real output. Functionally fine, but it's a lot of small allocations for code that runs on every stats-flush interval.

So I would say take a look and see if anything can be improved based on the existing serializers or nah.

Not blocking — if flush intervals are short or there are many distinct stat buckets, a pooled/reusable buffer would reduce GC pressure.

Aside from the above if you think the first comment is relevant to apply spec wise or not, let me know then we could merge if the change is worth it since the AI flag it as request changes worth.

Comment thread tracer/src/Datadog.Trace/Agent/StatsAggregator.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/StatsAggregator.cs Outdated

@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.

Updating my review to 'Request changes' so we don't accidentally merge the sampling-based weighting in the most recent changes. Once that's reverted I'll update my review back to 'Approve'

mabdinur and others added 3 commits July 9, 2026 09:40
… sentinel

- Remove GetWeight and revert to unweighted Hits/Errors/Duration/TopLevelHits,
  aligning with the intentional removal in PR #8828
- Revert StatsBucket fields back to long (no fractional weights needed)
- Remove (long) casts in StatsBuffer now that fields are long again
- Fix MaxDuration sentinel: use long.MinValue instead of 0 so zero-duration
  spans are correctly recorded and emitted
- Remove (long) cast on bucket.Duration in serializer (field is long again)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Covers the long.MinValue sentinel fix: a span with duration 0 must emit
min=0 and max=0, distinct from the "never observed" sentinel.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Reverts the GlobalTags/DD_TAGS resource-attribute emission added to the
OTLP span metrics serializer (commit 1dd837e). Removes both the JSON and
protobuf tag loops, the TryParseTag helper, and the now-unused OpenTelemetry
using. The shared DdTags infrastructure (ClientStatsPayload, StatsBuffer
MsgPack path) is untouched. This will be reintroduced in a future PR.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@mabdinur
mabdinur requested a review from zacharycmontoya July 9, 2026 14:16

@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, thanks for the updates!

@mabdinur
mabdinur merged commit defe22f into master Jul 10, 2026
141 checks passed
@mabdinur
mabdinur deleted the munir/otlp-span-metrics branch July 10, 2026 14:01
@github-actions github-actions Bot added this to the vNext-v3 milestone Jul 10, 2026
zacharycmontoya added a commit that referenced this pull request Jul 14, 2026
…race compatibility (#8796)

## Summary of changes
Adds an opt-in OpenTelemetry semantics mode for OTLP trace export.

This feature is enabled by setting
`DD_TRACE_OTEL_SEMANTICS_ENABLED=true`, which was previously introduced
in #8826. When enabled,
spans produced from OpenTelemetry instrumentation are serialized closer
to native OpenTelemetry SDK output by preserving OTel attribute keys and
value types, and by suppressing Datadog-specific attributes from OTLP
trace payloads.

## Reason for change
We should support scenarios where customers use the Datadog SDK but want
their emitted OTLP data to look as close as possible to data produced by
the OpenTelemetry SDK. This helps users route Datadog-instrumented
applications through OTel collectors or other OTLP consumers without the
payload including Datadog-specific span attributes that are not part of
the OpenTelemetry semantic conventions.

## Implementation details

Refactors
- Refactors the existing `SetExceptionTags` flow into
`SetException(exception, markAsError)` so callers can add exception
metadata without forcing the span error flag.

Instrumentation changes:
- Propagates the setting to `OtlpHelpers` so, when enabled, the
Activity-to-span conversion does not do any attribute remapping or
special handling for Datadog-specific attributes, preserving the
original attribute keys and values on the OTLP span.
- This also stops us from adding deprecated attributes such as
`otel.trace_id`, `otel.library.name`, `otel.library.version`, and
`otel.status_code` to match newer OTel SDK behaviors.

Span changes:
- Propagates the setting into a Span field so, when enabled, exceptions
are recorded as the OpenTelemetry `exception` span event with
`exception.type`, `exception.message`, and `exception.stacktrace`
attributes instead of Datadog error tags.

OTLP Exporter changes
- Updates `OtlpMapper.EmitAttributesFromSpan` so OTel semantics mode
suppresses Datadog-specific or compatibility-only span attributes,
including `service.name`, `operation.name`, `resource.name`,
`span.type`, `component`, `span.kind`, `service.version`,
`service.instance.id`, `otel.status_code`, and
`http-client-handler-type`.

Test changes
- Stabilizes the OTLP trace integration test by polling the test agent
for trace data after sample shutdown.

## Test coverage
- Adds unit coverage for `OtlpMapper` to assert Datadog attributes are
emitted by default and suppressed when OTel semantics mode is enabled.
- Adds unit coverage for preserving `http.status_code` and
`http.response.status_code` as OTel attributes when OTel semantics mode
is enabled.
- Adds unit coverage for the new `Span.SetException` behavior, including
exception span event creation under OTel semantics mode.
- Updates OTLP serializer tests for the new serializer configuration
path.
- Expands `OpenTelemetrySdkTests.SubmitsOtlpTraces` to run with
`DD_TRACE_OTEL_SEMANTICS_ENABLED` enabled and disabled for both
`http/json` and `http/protobuf`, adding a new
`OpenTelemetrySdkTests.SubmitsOtlpTraces_DD_OtelSemantics.verified.txt`
snapshot file.
- Miscellaneous: Updates out-of-date OpenTelemetrySdkTests snapshot
files with the JSON/Protobuf normalizations

## Other details
N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants