Skip to content

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

Open
mabdinur wants to merge 18 commits into
masterfrom
munir/otlp-span-metrics
Open

[OTLP] Add trace metrics via OTLP span metrics export#8826
mabdinur wants to merge 18 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
duration72.61 ± (72.53 - 73.10) ms73.10 ± (72.85 - 73.36) ms+0.7%✅⬆️
.NET Framework 4.8 - Bailout
duration76.18 ± (75.89 - 76.51) ms76.19 ± (75.94 - 76.38) ms+0.0%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1081.13 ± (1080.77 - 1087.48) ms1081.05 ± (1081.68 - 1088.85) ms-0.0%
.NET Core 3.1 - Baseline
process.internal_duration_ms22.52 ± (22.48 - 22.56) ms22.23 ± (22.18 - 22.28) ms-1.3%
process.time_to_main_ms82.91 ± (82.65 - 83.17) ms83.08 ± (82.77 - 83.39) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.91 ± (10.90 - 10.91) MB10.92 ± (10.92 - 10.92) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.26 ± (22.23 - 22.29) ms21.93 ± (21.90 - 21.97) ms-1.5%
process.time_to_main_ms81.78 ± (81.61 - 81.95) ms82.19 ± (82.01 - 82.38) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.95 ± (10.95 - 10.96) MB10.95 ± (10.95 - 10.95) MB-0.0%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms209.24 ± (208.42 - 210.06) ms212.69 ± (211.80 - 213.58) ms+1.6%✅⬆️
process.time_to_main_ms531.19 ± (530.02 - 532.35) ms531.77 ± (530.59 - 532.96) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.18 ± (49.14 - 49.21) MB49.23 ± (49.20 - 49.26) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.0%
.NET 6 - Baseline
process.internal_duration_ms20.79 ± (20.76 - 20.82) ms20.87 ± (20.84 - 20.90) ms+0.4%✅⬆️
process.time_to_main_ms69.31 ± (69.18 - 69.44) ms70.08 ± (69.92 - 70.23) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.63 ± (10.63 - 10.63) MB10.64 ± (10.64 - 10.65) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.11 ± (21.06 - 21.16) ms20.80 ± (20.77 - 20.83) ms-1.5%
process.time_to_main_ms72.50 ± (72.25 - 72.74) ms70.70 ± (70.57 - 70.82) ms-2.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.74 ± (10.74 - 10.75) MB10.75 ± (10.75 - 10.76) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms372.27 ± (370.17 - 374.37) ms372.67 ± (370.42 - 374.92) ms+0.1%✅⬆️
process.time_to_main_ms535.42 ± (534.29 - 536.56) ms536.00 ± (534.67 - 537.33) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed50.26 ± (50.23 - 50.28) MB50.32 ± (50.30 - 50.35) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms19.27 ± (19.23 - 19.30) ms19.39 ± (19.35 - 19.44) ms+0.7%✅⬆️
process.time_to_main_ms70.06 ± (69.81 - 70.32) ms71.96 ± (71.72 - 72.21) ms+2.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.66 ± (7.66 - 7.67) MB7.67 ± (7.67 - 7.68) MB+0.2%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.02 ± (18.98 - 19.05) ms19.08 ± (19.05 - 19.11) ms+0.3%✅⬆️
process.time_to_main_ms69.87 ± (69.77 - 69.98) ms70.70 ± (70.56 - 70.85) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.71 - 7.72) MB7.74 ± (7.73 - 7.75) MB+0.3%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms297.21 ± (294.99 - 299.44) ms295.99 ± (293.54 - 298.44) ms-0.4%
process.time_to_main_ms486.41 ± (485.40 - 487.42) ms486.37 ± (485.33 - 487.42) ms-0.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed37.63 ± (37.60 - 37.66) MB37.75 ± (37.72 - 37.78) MB+0.3%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)-0.6%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration204.88 ± (204.70 - 205.59) ms204.31 ± (203.98 - 204.96) ms-0.3%
.NET Framework 4.8 - Bailout
duration207.48 ± (206.64 - 207.81) ms207.00 ± (206.74 - 207.41) ms-0.2%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1213.52 ± (1212.39 - 1218.47) ms1211.90 ± (1210.24 - 1215.87) ms-0.1%
.NET Core 3.1 - Baseline
process.internal_duration_ms196.15 ± (195.78 - 196.52) ms196.38 ± (195.92 - 196.83) ms+0.1%✅⬆️
process.time_to_main_ms85.62 ± (85.30 - 85.95) ms85.67 ± (85.36 - 85.99) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.03 ± (16.01 - 16.05) MB16.06 ± (16.04 - 16.08) MB+0.2%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-1.2%
.NET Core 3.1 - Bailout
process.internal_duration_ms196.95 ± (196.53 - 197.36) ms195.86 ± (195.55 - 196.17) ms-0.6%
process.time_to_main_ms87.34 ± (87.07 - 87.62) ms86.45 ± (86.24 - 86.65) ms-1.0%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.10 ± (16.07 - 16.12) MB16.00 ± (15.98 - 16.03) MB-0.6%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (20 - 21)-0.1%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms387.50 ± (386.10 - 388.89) ms389.21 ± (388.03 - 390.38) ms+0.4%✅⬆️
process.time_to_main_ms546.28 ± (544.81 - 547.74) ms546.02 ± (544.77 - 547.27) ms-0.0%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.48 ± (58.26 - 58.71) MB58.45 ± (58.23 - 58.67) MB-0.1%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.6%
.NET 6 - Baseline
process.internal_duration_ms201.55 ± (201.11 - 201.99) ms199.36 ± (198.97 - 199.75) ms-1.1%
process.time_to_main_ms74.45 ± (74.19 - 74.71) ms73.79 ± (73.52 - 74.07) ms-0.9%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.35 ± (16.32 - 16.38) MB16.43 ± (16.40 - 16.46) MB+0.5%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.1%
.NET 6 - Bailout
process.internal_duration_ms200.10 ± (199.78 - 200.41) ms197.12 ± (196.73 - 197.50) ms-1.5%
process.time_to_main_ms75.29 ± (75.07 - 75.51) ms74.16 ± (73.95 - 74.36) ms-1.5%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.45 ± (16.43 - 16.47) MB16.46 ± (16.43 - 16.48) MB+0.1%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+0.6%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms586.39 ± (583.79 - 588.99) ms587.74 ± (585.38 - 590.10) ms+0.2%✅⬆️
process.time_to_main_ms557.23 ± (556.17 - 558.28) ms554.49 ± (553.39 - 555.60) ms-0.5%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed61.39 ± (61.31 - 61.47) MB61.39 ± (61.31 - 61.47) MB-0.0%
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)-0.2%
.NET 8 - Baseline
process.internal_duration_ms200.49 ± (199.98 - 201.00) ms198.20 ± (197.77 - 198.64) ms-1.1%
process.time_to_main_ms74.26 ± (73.99 - 74.53) ms73.62 ± (73.40 - 73.85) ms-0.9%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.70 ± (11.68 - 11.71) MB11.78 ± (11.76 - 11.79) MB+0.7%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 19)19 ± (18 - 19)+0.2%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms199.14 ± (198.69 - 199.58) ms197.49 ± (197.03 - 197.94) ms-0.8%
process.time_to_main_ms75.13 ± (74.90 - 75.36) ms74.37 ± (74.16 - 74.58) ms-1.0%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.76 ± (11.74 - 11.78) MB11.81 ± (11.80 - 11.83) MB+0.4%✅⬆️
runtime.dotnet.threads.count20 ± (19 - 20)19 ± (19 - 19)-1.2%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms512.35 ± (509.52 - 515.17) ms512.15 ± (509.05 - 515.25) ms-0.0%
process.time_to_main_ms503.80 ± (502.89 - 504.71) ms503.58 ± (502.64 - 504.51) ms-0.0%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed51.09 ± (51.05 - 51.12) MB51.16 ± (51.12 - 51.21) MB+0.2%✅⬆️
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (29 - 30)-0.7%
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 (73ms)  : 69, 77
    master - mean (73ms)  : 69, 77

    section Bailout
    This PR (8826) - mean (76ms)  : 73, 79
    master - mean (76ms)  : 72, 81

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,085ms)  : 1033, 1137
    master - mean (1,084ms)  : 1036, 1132

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 (113ms)  : 105, 120
    master - mean (113ms)  : 108, 118

    section Bailout
    This PR (8826) - mean (111ms)  : 108, 113
    master - mean (111ms)  : 108, 113

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (782ms)  : 754, 809
    master - mean (777ms)  : 752, 801

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

    section Bailout
    This PR (8826) - mean (98ms)  : 95, 100
    master - mean (100ms)  : 95, 105

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (942ms)  : 899, 984
    master - mean (939ms)  : 895, 982

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8826) - mean (99ms)  : 94, 104
    master - mean (96ms)  : 90, 102

    section Bailout
    This PR (8826) - mean (97ms)  : 93, 100
    master - mean (95ms)  : 94, 97

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (814ms)  : 773, 855
    master - mean (813ms)  : 779, 848

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 (204ms)  : 199, 210
    master - mean (205ms)  : 200, 211

    section Bailout
    This PR (8826) - mean (207ms)  : 204, 210
    master - mean (207ms)  : 201, 213

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,213ms)  : 1175, 1251
    master - mean (1,215ms)  : 1172, 1259

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 (292ms)  : 283, 301
    master - mean (291ms)  : 286, 297

    section Bailout
    This PR (8826) - mean (292ms)  : 289, 296
    master - mean (294ms)  : 289, 299

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (977ms)  : 947, 1008
    master - mean (974ms)  : 954, 995

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

    section Bailout
    This PR (8826) - mean (280ms)  : 275, 286
    master - mean (284ms)  : 280, 288

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,176ms)  : 1139, 1212
    master - mean (1,176ms)  : 1138, 1215

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, 289
    master - mean (287ms)  : 281, 293

    section Bailout
    This PR (8826) - mean (282ms)  : 275, 290
    master - mean (286ms)  : 277, 294

    section CallTarget+Inlining+NGEN
    This PR (8826) - mean (1,047ms)  : 999, 1095
    master - mean (1,050ms)  : 1012, 1088

Loading

@pr-commenter

pr-commenter Bot commented Jun 25, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-02 17:33:51

Comparing candidate commit f93b8f5 in PR branch munir/otlp-span-metrics with baseline commit 93bb6e6 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 1 performance regressions! Performance is the same for 71 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 ----------------------------------'

scenario:Benchmarks.Trace.HttpClientBenchmark.SendAsync net472

  • 🟥 throughput [-4818.496op/s; -4503.241op/s] or [-5.501%; -5.141%]

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 [-8035.002op/s; -7500.187op/s] or [-9.527%; -8.893%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+323.905ms; +325.747ms] or [+160.733%; +161.647%]
  • 🟥 throughput [-40.883op/s; -37.157op/s] or [-7.356%; -6.685%]

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

  • 🟥 execution_time [+380.319ms; +382.190ms] or [+300.475%; +301.954%]
  • 🟩 throughput [+96.262op/s; +100.715op/s] or [+12.692%; +13.279%]

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

  • 🟥 execution_time [+389.969ms; +391.708ms] or [+345.108%; +346.647%]

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 [-15.798ms; -11.610ms] or [-7.378%; -5.422%]
  • 🟩 throughput [+7776.842op/s; +10599.739op/s] or [+5.677%; +7.737%]

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 [-266817.565op/s; -262537.777op/s] or [-27.243%; -26.806%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.557%; +38.566%]
  • 🟩 execution_time [-26.577ms; -21.704ms] or [-11.852%; -9.679%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.288%; +105.304%]
  • 🟥 throughput [-147115.522op/s; -131126.761op/s] or [-21.138%; -18.840%]

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

  • 🟩 throughput [+8373.215op/s; +11367.437op/s] or [+5.328%; +7.233%]

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

  • 🟩 throughput [+8456.798op/s; +11163.909op/s] or [+6.737%; +8.894%]

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

  • 🟩 throughput [+409468.237op/s; +481489.424op/s] or [+13.653%; +16.055%]

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

  • 🟩 execution_time [-19.004ms; -14.672ms] or [-8.760%; -6.763%]

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

  • 🟥 execution_time [+297.675ms; +299.244ms] or [+148.738%; +149.522%]

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

  • 🟥 execution_time [+299.631ms; +302.745ms] or [+151.105%; +152.675%]
  • 🟩 throughput [+659.022op/s; +868.738op/s] or [+5.041%; +6.645%]

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

  • 🟥 execution_time [+300.544ms; +303.770ms] or [+151.391%; +153.016%]

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

  • 🟥 execution_time [+297.037ms; +297.976ms] or [+145.893%; +146.354%]

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

  • 🟥 execution_time [+294.045ms; +298.036ms] or [+143.748%; +145.699%]

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

  • 🟥 execution_time [+301.414ms; +302.857ms] or [+150.646%; +151.368%]

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

  • 🟥 execution_time [+23.748µs; +47.782µs] or [+7.581%; +15.254%]
  • 🟥 throughput [-441.730op/s; -239.779op/s] or [-13.770%; -7.475%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.472ms; +300.339ms] or [+149.467%; +149.900%]

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

  • 🟥 execution_time [+402.781ms; +409.053ms] or [+437.638%; +444.453%]
  • 🟩 throughput [+910.306op/s; +1075.657op/s] or [+7.480%; +8.839%]

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

  • unstable execution_time [+264.466ms; +319.936ms] or [+200.806%; +242.924%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+331.265ms; +393.164ms] or [+152.312%; +180.773%]
  • 🟥 throughput [-550.024op/s; -507.498op/s] or [-49.838%; -45.984%]

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

  • unstable execution_time [+146.623ms; +292.820ms] or [+62.485%; +124.788%]
  • 🟥 throughput [-668.199op/s; -584.756op/s] or [-44.569%; -39.003%]

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

  • 🟥 execution_time [+355.064ms; +368.014ms] or [+212.369%; +220.115%]
  • 🟥 throughput [-467.732op/s; -429.188op/s] or [-32.568%; -29.884%]

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

  • 🟩 throughput [+25.971op/s; +44.023op/s] or [+5.127%; +8.690%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+302.269ms; +304.007ms] or [+152.217%; +153.092%]

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

  • 🟥 execution_time [+297.300ms; +310.956ms] or [+148.978%; +155.821%]

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

  • 🟥 execution_time [+301.268ms; +304.446ms] or [+151.344%; +152.941%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+303.211ms; +305.945ms] or [+152.262%; +153.635%]

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

  • 🟥 execution_time [+298.726ms; +301.303ms] or [+147.707%; +148.981%]

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

  • 🟥 execution_time [+301.102ms; +304.866ms] or [+152.612%; +154.520%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+302.748ms; +304.832ms] or [+151.952%; +152.998%]

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

  • 🟥 execution_time [+300.748ms; +304.523ms] or [+149.895%; +151.777%]
  • 🟩 throughput [+33332.146op/s; +44485.674op/s] or [+6.619%; +8.833%]

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

  • 🟥 execution_time [+301.968ms; +304.924ms] or [+150.226%; +151.697%]

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

  • 🟩 execution_time [-16.735ms; -13.050ms] or [-7.782%; -6.068%]
  • 🟩 throughput [+23360.377op/s; +30243.770op/s] or [+6.408%; +8.297%]

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

  • unstable execution_time [+16.335µs; +60.968µs] or [+4.035%; +15.060%]

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

  • 🟩 allocated_mem [-20.471KB; -20.450KB] or [-7.467%; -7.460%]
  • unstable execution_time [+13.846µs; +117.077µs] or [+2.737%; +23.140%]
  • unstable throughput [-278.604op/s; +1.852op/s] or [-13.902%; +0.092%]

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

  • unstable execution_time [-81.464µs; -19.389µs] or [-14.117%; -3.360%]
  • unstable throughput [+83.171op/s; +261.752op/s] or [+4.752%; +14.954%]

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

  • unstable execution_time [+6.229µs; +10.966µs] or [+14.722%; +25.920%]
  • 🟥 throughput [-4859.863op/s; -2945.590op/s] or [-20.458%; -12.400%]

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

  • unstable execution_time [-14.723µs; -7.055µs] or [-22.842%; -10.946%]
  • unstable throughput [+1797.313op/s; +3469.641op/s] or [+11.027%; +21.287%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+301.168ms; +302.384ms] or [+152.227%; +152.842%]

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

  • 🟥 execution_time [+299.651ms; +303.212ms] or [+152.521%; +154.334%]

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

  • 🟥 execution_time [+298.587ms; +301.037ms] or [+149.479%; +150.706%]

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

  • 🟩 throughput [+32099.932op/s; +35650.105op/s] or [+6.076%; +6.748%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+299.577ms; +301.898ms] or [+149.312%; +150.469%]

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

  • 🟥 execution_time [+300.865ms; +302.553ms] or [+151.080%; +151.927%]

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

  • 🟥 execution_time [+301.384ms; +304.192ms] or [+152.843%; +154.267%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+298.041ms; +298.912ms] or [+148.665%; +149.099%]
  • 🟩 throughput [+61362483.611op/s; +61661143.794op/s] or [+44.688%; +44.905%]

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

  • 🟥 execution_time [+417.456ms; +421.739ms] or [+519.181%; +524.508%]

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

  • 🟥 execution_time [+299.354ms; +300.388ms] or [+149.311%; +149.827%]

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

  • 🟩 throughput [+80280.592op/s; +91018.946op/s] or [+7.496%; +8.498%]

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

  • 🟩 throughput [+58170.817op/s; +77439.576op/s] or [+6.733%; +8.963%]

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

  • 🟩 throughput [+84460.925op/s; +115191.610op/s] or [+6.537%; +8.916%]

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

  • 🟩 throughput [+83951.316op/s; +93703.350op/s] or [+8.338%; +9.306%]

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

  • 🟩 throughput [+39680.569op/s; +46977.630op/s] or [+7.205%; +8.530%]

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

  • 🟩 throughput [+27628.478op/s; +37372.823op/s] or [+6.184%; +8.365%]

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

  • 🟩 throughput [+86658.462op/s; +103599.724op/s] or [+9.682%; +11.575%]

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 net6.0
  • 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.OptimizedCharSlice netcoreapp3.1
  • 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.StartFinishSpan net472
  • 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
@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 Outdated
Comment thread tracer/src/Datadog.Trace/Agent/OtlpSpanStatsSerializer.cs Outdated
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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <cursoragent@cursor.com>
…ve stale comments

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ctory

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
StatsBucket, StatsBuffer, and StatsAggregationKey constructors gained new
required parameters in master; update test call sites to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mabdinur and others added 2 commits July 2, 2026 12:12
CanComputeStats controls P0 dropping and must be true in OTLP mode so
unsampled traces are not forwarded. IsClientComputingStats separately
controls whether _dd.stats_computed=true is emitted on OTLP traces, and
is only true when span metrics are actually exported.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
// sampling decision override takes precedence over TraceContext.SamplingPriority
SamplingPriority = samplingPriority;
IsFirstChunkInPayload = isFirstChunkInPayload;
ClientComputedStats = clientComputedStats;

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.

You should calculate ClientComputedStats from the tracer settings, like how IsApmEnabled is calculated. As a result, you can remove the bool clientComputedStats parameter from being passed into this file, AgentWriter.cs, and SpanBuffer.cs. This should also let you eliminate AgentWriter.ClientComputedStats

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 should also allow you to delete the property IStatsAggregator.IsClientComputingStats

}

private async Task<bool> SendWithRetry<T>(Uri endpoint, SendCallback<T> callback, T state, int retryLimit = 5)
private async Task<bool> SendWithRetry<T>(Uri endpoint, SendCallback<T> callback, T state, int retryLimit = 5, IApiRequestFactory requestFactory = null)

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.

Let's make the IApiRequestFactory requestFactory field mandatory so we don't create diverging logic between the OTLP Traces and OTLP Span Metrics.

Suggested change
private async Task<bool> SendWithRetry<T>(Uri endpoint, SendCallback<T> callback, T state, int retryLimit = 5, IApiRequestFactory requestFactory = null)
private async Task<bool> SendWithRetry<T>(Uri endpoint, IApiRequestFactory requestFactory, SendCallback<T> callback, T state, int retryLimit = 5)

WriteVarInt(writer, resourceData.Length);
writer.Write(resourceData);

// Single scope-metrics entry (no InstrumentationScope — omitted per spec)

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.

Is the InstrumentationScope omitted omitted in our own spec or in the Span Metrics Connector? We should give it a similar shape to the SMC I would imagine

return stream.ToArray();
}

private static byte[] SerializeResource(StatsBuffer buffer, 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.

The resource we emit here should match the resource emitted by the existing OtlpMetricsSerializer (it currently only emits protobuf). Can you please ensure their resource header is produced identically?

writer.Write(endTimeUnixNano);

var count = (ulong)bucket.Hits;
WriteTag(writer, FieldNumbers.HistogramDataPointCount, WireTypeVarInt);

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.

I think this should be a fixed64 not a varint

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.

3 participants