Skip to content

[Runtime Metrics] Support for OTLP Runtime Metrics#8457

Open
link04 wants to merge 20 commits intomasterfrom
maximo/otlp-runtime-metrics
Open

[Runtime Metrics] Support for OTLP Runtime Metrics#8457
link04 wants to merge 20 commits intomasterfrom
maximo/otlp-runtime-metrics

Conversation

@link04
Copy link
Copy Markdown
Contributor

@link04 link04 commented Apr 14, 2026

Summary of changes

Add support for exporting .NET runtime metrics via OTLP, using OpenTelemetry semantic convention names. When both DD_RUNTIME_METRICS_ENABLED=true and DD_METRICS_OTEL_ENABLED=true, runtime metrics (System.Runtime, ASP.NET Core) are collected through the existing OTLP metrics pipeline instead of DogStatsD.

Related One Pager: Sending Runtime Metrics via OTLP from dd-trace-*

Reason for change

Enables runtime visibility for users on OTLP-native pipelines or without a local Datadog Agent. Aligns .NET runtime metric names with OTel semantic conventions (dotnet.gc.collections, dotnet.process.cpu.time, etc.).

Implementation details

  • TracerSettings: New OtlpRuntimeMetricsEnabled property to check if OTLP Metrics and Runtime Metrics are enabled simultaneously .
  • TracerManagerFactory: Disables StatsD RuntimeMetricsWriter when OTLP runtime metrics are active to prevent duplicate reporting.
  • MetricReaderHandler: Adds System.Runtime, Microsoft.AspNetCore.Hosting, and Microsoft.AspNetCore.Server.Kestrel meters when OtlpRuntimeMetricsEnabled is true, even if not explicitly listed in DD_METRICS_OTEL_METER_NAMES.
  • RuntimeMetricsPolyfill (new): Provides .NET 9+ native System.Runtime meter instruments for .NET 6-8 using System.Diagnostics.Metrics. Includes counter reset detection for ObservableCounter.
  • MetricsRuntime: Starts polyfill on .NET <9; added thread-safe initialization.

Test coverage

  • OpenTelemetrySdkTests.SubmitsOtlpRuntimeMetrics: End-to-end integration test verifying OTLP runtime metrics payload via Verify snapshots (separate snapshots for .NET 6 and .NET 9 due to polyfill type differences). Confirms StatsD is not emitted when OTLP runtime metrics are active.
  • RuntimeMetricsMeterTests.InstrumentSurface: Unit test verifying the polyfill exposes the correct set of instruments on both .NET 6 and .NET 9.
  • Added DD_RUNTIME_METRICS_ENABLED=false to existing SubmitsOtlpMetrics test to prevent runtime metrics from interfering with custom meter assertions.

Other details

  • Built against system tests PR (system-tests repo) , added need DD_RUNTIME_METRICS_ENABLED=false added to their DEFAULT_ENVVARS to avoid unexpected runtime metrics in OTel metric assertions and created new test based on language expectations.

@dd-trace-dotnet-ci-bot
Copy link
Copy Markdown

dd-trace-dotnet-ci-bot Bot commented Apr 14, 2026

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8457) 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
duration73.08 ± (73.16 - 73.53) ms75.75 ± (75.74 - 76.37) ms+3.7%✅⬆️
.NET Framework 4.8 - Bailout
duration79.52 ± (79.37 - 79.91) ms78.12 ± (78.01 - 78.47) ms-1.8%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1076.92 ± (1071.03 - 1080.94) ms1078.59 ± (1078.54 - 1085.99) ms+0.2%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms22.56 ± (22.51 - 22.62) ms22.82 ± (22.76 - 22.88) ms+1.1%✅⬆️
process.time_to_main_ms85.09 ± (84.84 - 85.35) ms86.51 ± (86.24 - 86.79) ms+1.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.86 ± (10.86 - 10.87) MB10.92 ± (10.91 - 10.92) MB+0.5%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.36 ± (22.32 - 22.41) ms22.46 ± (22.42 - 22.49) ms+0.4%✅⬆️
process.time_to_main_ms85.45 ± (85.23 - 85.67) ms85.69 ± (85.48 - 85.90) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.94 ± (10.94 - 10.94) MB10.94 ± (10.93 - 10.94) MB-0.0%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms212.85 ± (211.97 - 213.73) ms213.91 ± (212.99 - 214.83) ms+0.5%✅⬆️
process.time_to_main_ms527.85 ± (526.55 - 529.14) ms530.03 ± (528.67 - 531.39) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed47.87 ± (47.84 - 47.90) MB47.88 ± (47.85 - 47.90) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.0%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms21.29 ± (21.24 - 21.34) ms21.85 ± (21.80 - 21.91) ms+2.7%✅⬆️
process.time_to_main_ms74.58 ± (74.32 - 74.84) ms76.65 ± (76.34 - 76.96) ms+2.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.61 ± (10.61 - 10.62) MB10.63 ± (10.63 - 10.63) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.00 ± (20.96 - 21.04) ms21.46 ± (21.41 - 21.51) ms+2.2%✅⬆️
process.time_to_main_ms74.17 ± (74.00 - 74.34) ms76.11 ± (75.81 - 76.41) ms+2.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.73 ± (10.73 - 10.73) MB10.74 ± (10.74 - 10.74) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms380.48 ± (378.38 - 382.58) ms381.18 ± (379.15 - 383.21) ms+0.2%✅⬆️
process.time_to_main_ms530.19 ± (528.87 - 531.50) ms531.32 ± (529.77 - 532.87) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.31 ± (49.28 - 49.34) MB49.54 ± (49.51 - 49.56) MB+0.5%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.0%
.NET 8 - Baseline
process.internal_duration_ms19.39 ± (19.36 - 19.41) ms19.63 ± (19.60 - 19.67) ms+1.3%✅⬆️
process.time_to_main_ms72.90 ± (72.72 - 73.08) ms73.39 ± (73.21 - 73.58) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.68 ± (7.67 - 7.69) MB7.65 ± (7.64 - 7.65) MB-0.4%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.80 ± (19.76 - 19.85) ms20.15 ± (20.10 - 20.21) ms+1.8%✅⬆️
process.time_to_main_ms76.49 ± (76.26 - 76.71) ms78.14 ± (77.88 - 78.39) ms+2.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.71 - 7.72) MB7.71 ± (7.70 - 7.71) MB-0.1%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms300.41 ± (298.39 - 302.43) ms300.08 ± (297.93 - 302.24) ms-0.1%
process.time_to_main_ms490.47 ± (489.27 - 491.66) ms493.30 ± (492.09 - 494.52) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.54 ± (36.51 - 36.57) MB36.51 ± (36.49 - 36.53) MB-0.1%
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.2%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration206.10 ± (205.94 - 207.26) ms203.24 ± (202.96 - 203.91) ms-1.4%
.NET Framework 4.8 - Bailout
duration210.05 ± (209.84 - 211.16) ms206.37 ± (206.25 - 207.29) ms-1.8%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1215.01 ± (1215.13 - 1221.81) ms1200.64 ± (1202.07 - 1209.28) ms-1.2%
.NET Core 3.1 - Baseline
process.internal_duration_ms198.13 ± (197.40 - 198.85) ms196.27 ± (195.75 - 196.79) ms-0.9%
process.time_to_main_ms86.50 ± (86.15 - 86.84) ms85.40 ± (85.12 - 85.67) ms-1.3%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.04 ± (16.03 - 16.06) MB16.03 ± (16.01 - 16.05) MB-0.1%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+1.1%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms198.37 ± (197.71 - 199.03) ms195.88 ± (195.37 - 196.38) ms-1.3%
process.time_to_main_ms87.76 ± (87.42 - 88.10) ms86.51 ± (86.26 - 86.76) ms-1.4%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.00 ± (15.98 - 16.01) MB16.08 ± (16.06 - 16.10) MB+0.5%✅⬆️
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)+0.8%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms394.01 ± (392.25 - 395.77) ms390.80 ± (389.65 - 391.95) ms-0.8%
process.time_to_main_ms541.33 ± (539.60 - 543.06) ms533.33 ± (532.10 - 534.55) ms-1.5%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.34 ± (58.19 - 58.49) MB58.21 ± (58.06 - 58.35) MB-0.2%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.1%
.NET 6 - Baseline
process.internal_duration_ms206.96 ± (206.13 - 207.79) ms201.40 ± (200.88 - 201.93) ms-2.7%
process.time_to_main_ms77.40 ± (76.96 - 77.83) ms74.21 ± (73.95 - 74.47) ms-4.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.24 ± (16.22 - 16.25) MB16.31 ± (16.30 - 16.33) MB+0.5%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-1.0%
.NET 6 - Bailout
process.internal_duration_ms204.60 ± (203.83 - 205.37) ms200.66 ± (200.13 - 201.20) ms-1.9%
process.time_to_main_ms76.35 ± (76.06 - 76.64) ms75.62 ± (75.37 - 75.86) ms-1.0%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.27 ± (16.25 - 16.28) MB16.35 ± (16.33 - 16.37) MB+0.5%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+0.6%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms593.92 ± (591.12 - 596.72) ms598.35 ± (595.82 - 600.88) ms+0.7%✅⬆️
process.time_to_main_ms537.75 ± (536.53 - 538.97) ms533.21 ± (532.08 - 534.35) ms-0.8%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed60.87 ± (60.77 - 60.98) MB61.05 ± (60.95 - 61.15) MB+0.3%✅⬆️
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)-0.3%
.NET 8 - Baseline
process.internal_duration_ms200.64 ± (200.12 - 201.16) ms199.18 ± (198.71 - 199.65) ms-0.7%
process.time_to_main_ms74.14 ± (73.90 - 74.38) ms73.46 ± (73.20 - 73.71) ms-0.9%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.62 ± (11.60 - 11.63) MB11.64 ± (11.62 - 11.66) MB+0.2%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)-0.2%
.NET 8 - Bailout
process.internal_duration_ms200.11 ± (199.58 - 200.64) ms199.35 ± (198.85 - 199.85) ms-0.4%
process.time_to_main_ms74.92 ± (74.68 - 75.16) ms74.61 ± (74.39 - 74.83) ms-0.4%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.65 ± (11.63 - 11.67) MB11.72 ± (11.71 - 11.74) MB+0.6%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)20 ± (19 - 20)+0.9%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms519.31 ± (516.14 - 522.47) ms520.28 ± (516.98 - 523.57) ms+0.2%✅⬆️
process.time_to_main_ms492.77 ± (491.79 - 493.74) ms491.71 ± (490.75 - 492.67) ms-0.2%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed50.32 ± (50.28 - 50.35) MB50.25 ± (50.22 - 50.28) MB-0.1%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.2%
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 (8457) - mean (76ms)  : 71, 81
    master - mean (73ms)  : 71, 76

    section Bailout
    This PR (8457) - mean (78ms)  : 75, 82
    master - mean (80ms)  : 76, 84

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (1,082ms)  : 1028, 1136
    master - mean (1,076ms)  : 1020, 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 (8457) - mean (117ms)  : 110, 123
    master - mean (115ms)  : 109, 121

    section Bailout
    This PR (8457) - mean (115ms)  : 112, 118
    master - mean (115ms)  : 112, 117

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (780ms)  : 756, 804
    master - mean (779ms)  : 750, 808

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8457) - mean (105ms)  : 99, 112
    master - mean (102ms)  : 98, 107

    section Bailout
    This PR (8457) - mean (104ms)  : 97, 111
    master - mean (101ms)  : 99, 104

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (940ms)  : 905, 975
    master - mean (940ms)  : 894, 985

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8457) - mean (101ms)  : 97, 105
    master - mean (100ms)  : 97, 104

    section Bailout
    This PR (8457) - mean (107ms)  : 102, 112
    master - mean (105ms)  : 100, 109

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (824ms)  : 783, 865
    master - mean (822ms)  : 786, 859

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 (8457) - mean (203ms)  : 197, 210
    master - mean (207ms)  : 197, 216

    section Bailout
    This PR (8457) - mean (207ms)  : 199, 214
    master - mean (211ms)  : 201, 220

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (1,206ms)  : 1154, 1257
    master - mean (1,218ms)  : 1170, 1267

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 (8457) - mean (291ms)  : 282, 301
    master - mean (296ms)  : 278, 314

    section Bailout
    This PR (8457) - mean (292ms)  : 280, 303
    master - mean (297ms)  : 280, 313

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (965ms)  : 937, 993
    master - mean (976ms)  : 946, 1007

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8457) - mean (285ms)  : 274, 295
    master - mean (294ms)  : 274, 314

    section Bailout
    This PR (8457) - mean (286ms)  : 277, 294
    master - mean (292ms)  : 272, 311

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (1,160ms)  : 1122, 1199
    master - mean (1,163ms)  : 1111, 1215

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8457) - mean (283ms)  : 275, 292
    master - mean (285ms)  : 274, 297

    section Bailout
    This PR (8457) - mean (285ms)  : 272, 297
    master - mean (286ms)  : 275, 297

    section CallTarget+Inlining+NGEN
    This PR (8457) - mean (1,045ms)  : 995, 1095
    master - mean (1,044ms)  : 993, 1094

Loading

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Apr 14, 2026

Benchmarks

Benchmark execution time: 2026-04-29 20:17:14

Comparing candidate commit 2b2124a in PR branch maximo/otlp-runtime-metrics with baseline commit 27142fd in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics, 57 known flaky benchmarks, 30 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 net6.0

  • 🟩 throughput [+7425.762op/s; +9614.998op/s] or [+6.242%; +8.082%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+303.455ms; +308.004ms] or [+150.585%; +152.842%]
  • 🟥 throughput [-46.660op/s; -43.009op/s] or [-8.395%; -7.738%]

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

  • 🟥 execution_time [+376.385ms; +377.714ms] or [+297.367%; +298.417%]
  • 🟩 throughput [+100.950op/s; +104.063op/s] or [+13.310%; +13.720%]

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

  • 🟥 execution_time [+393.690ms; +396.547ms] or [+348.401%; +350.929%]

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

  • 🟥 allocated_mem [+1.308KB; +1.308KB] or [+27.529%; +27.541%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+9.977%; +9.987%]
  • 🟩 execution_time [-15.832ms; -11.667ms] or [-7.394%; -5.449%]

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

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

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

  • 🟥 allocated_mem [+1.307KB; +1.307KB] or [+105.746%; +105.759%]
  • 🟥 throughput [-263246.692op/s; -259819.302op/s] or [-26.879%; -26.529%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.558%; +38.566%]
  • 🟩 execution_time [-26.539ms; -18.190ms] or [-11.835%; -8.112%]
  • 🟥 throughput [-78132.465op/s; -49698.692op/s] or [-8.347%; -5.309%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.292%; +105.304%]
  • 🟥 throughput [-142241.976op/s; -126166.403op/s] or [-20.437%; -18.128%]

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

  • 🟩 throughput [+334459.550op/s; +354677.523op/s] or [+11.152%; +11.826%]

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

  • 🟩 execution_time [-19.299ms; -14.757ms] or [-8.896%; -6.802%]
  • 🟩 throughput [+133289.670op/s; +195018.616op/s] or [+5.291%; +7.741%]

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

  • 🟥 execution_time [+300.071ms; +300.628ms] or [+149.935%; +150.214%]

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

  • 🟥 execution_time [+298.860ms; +302.101ms] or [+150.716%; +152.350%]

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

  • 🟥 execution_time [+300.204ms; +302.731ms] or [+151.219%; +152.493%]

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

  • 🟥 execution_time [+296.070ms; +296.675ms] or [+145.418%; +145.715%]

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

  • 🟥 execution_time [+296.035ms; +298.771ms] or [+144.720%; +146.058%]

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

  • 🟥 execution_time [+301.157ms; +302.547ms] or [+150.518%; +151.213%]

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

  • 🟥 execution_time [+29.241µs; +56.066µs] or [+6.707%; +12.859%]
  • 🟥 throughput [-270.372op/s; -149.827op/s] or [-11.755%; -6.514%]

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

  • 🟥 execution_time [+39.077µs; +63.606µs] or [+12.475%; +20.306%]
  • 🟥 throughput [-560.975op/s; -358.049op/s] or [-17.487%; -11.161%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.744ms; +300.422ms] or [+149.603%; +149.941%]

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

  • 🟥 execution_time [+411.087ms; +417.076ms] or [+446.663%; +453.170%]
  • 🟩 throughput [+1148.884op/s; +1272.215op/s] or [+9.441%; +10.454%]

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

  • unstable execution_time [+333.991ms; +362.610ms] or [+253.596%; +275.326%]
  • 🟩 throughput [+624.949op/s; +829.636op/s] or [+6.050%; +8.031%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+318.030ms; +348.722ms] or [+146.227%; +160.339%]
  • 🟥 throughput [-514.348op/s; -484.638op/s] or [-46.605%; -43.913%]

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

  • unstable execution_time [+209.534ms; +342.737ms] or [+89.295%; +146.060%]
  • 🟥 throughput [-663.837op/s; -580.397op/s] or [-44.278%; -38.713%]

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

  • 🟥 execution_time [+343.240ms; +352.508ms] or [+205.298%; +210.840%]
  • 🟥 throughput [-418.277op/s; -383.790op/s] or [-29.124%; -26.723%]

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

  • 🟩 execution_time [-144.970µs; -102.951µs] or [-7.344%; -5.215%]
  • 🟩 throughput [+30.052op/s; +41.008op/s] or [+5.933%; +8.095%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+302.823ms; +304.520ms] or [+152.496%; +153.351%]

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

  • 🟥 execution_time [+301.769ms; +303.514ms] or [+151.217%; +152.091%]

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

  • 🟥 execution_time [+302.006ms; +305.214ms] or [+151.715%; +153.327%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+301.299ms; +302.554ms] or [+151.302%; +151.932%]

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

  • 🟥 execution_time [+297.876ms; +299.748ms] or [+147.287%; +148.212%]

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

  • 🟥 execution_time [+302.683ms; +306.091ms] or [+153.413%; +155.140%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+301.487ms; +303.030ms] or [+151.319%; +152.094%]

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

  • 🟥 execution_time [+302.388ms; +304.614ms] or [+150.713%; +151.822%]
  • 🟩 throughput [+31678.626op/s; +37816.200op/s] or [+6.290%; +7.509%]

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

  • 🟥 execution_time [+300.182ms; +302.816ms] or [+149.338%; +150.648%]

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

  • 🟩 allocated_mem [-19.268KB; -19.247KB] or [-7.029%; -7.021%]
  • unstable execution_time [-35.745µs; +16.446µs] or [-7.065%; +3.250%]

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

  • 🟩 allocated_mem [-18.772KB; -18.756KB] or [-6.843%; -6.838%]

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

  • 🟥 execution_time [+6.814µs; +10.785µs] or [+16.106%; +25.492%]
  • 🟥 throughput [-4898.134op/s; -3158.887op/s] or [-20.620%; -13.298%]

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

  • unstable execution_time [-15.070µs; -8.138µs] or [-23.380%; -12.626%]
  • 🟩 throughput [+2108.687op/s; +3565.667op/s] or [+12.937%; +21.877%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+301.736ms; +302.720ms] or [+152.514%; +153.011%]

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

  • 🟥 execution_time [+303.390ms; +305.552ms] or [+154.425%; +155.525%]

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

  • 🟥 execution_time [+300.286ms; +302.724ms] or [+150.330%; +151.551%]

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

  • 🟩 throughput [+45936.632op/s; +49208.597op/s] or [+8.695%; +9.314%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+300.464ms; +302.580ms] or [+149.754%; +150.809%]

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

  • 🟥 execution_time [+301.988ms; +302.953ms] or [+151.644%; +152.129%]

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

  • 🟥 execution_time [+303.358ms; +306.039ms] or [+153.844%; +155.203%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+300.198ms; +300.862ms] or [+149.740%; +150.071%]
  • 🟩 throughput [+61219965.832op/s; +61492228.190op/s] or [+44.584%; +44.782%]

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

  • 🟥 execution_time [+424.815ms; +429.391ms] or [+528.333%; +534.024%]
  • 🟩 throughput [+1004.399op/s; +1184.043op/s] or [+7.765%; +9.153%]

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

  • 🟥 execution_time [+299.308ms; +300.206ms] or [+149.288%; +149.736%]

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

  • 🟩 throughput [+86918.881op/s; +98698.511op/s] or [+8.115%; +9.215%]

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

  • 🟩 throughput [+56270.034op/s; +75442.908op/s] or [+6.513%; +8.732%]

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

  • 🟩 throughput [+78789.522op/s; +110335.570op/s] or [+6.098%; +8.540%]

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

  • 🟩 throughput [+78822.121op/s; +88771.669op/s] or [+7.828%; +8.816%]

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

  • 🟩 throughput [+48997.817op/s; +55460.449op/s] or [+8.897%; +10.071%]

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

  • 🟩 throughput [+26734.887op/s; +36642.335op/s] or [+5.984%; +8.202%]

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

  • 🟩 throughput [+72298.543op/s; +90321.653op/s] or [+8.078%; +10.091%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody netcoreapp3.1
  • 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.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 net6.0
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472
  • 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

@link04 link04 added docker_image_artifacts Use to label PRs for which you would need a Docker Image created for. area:opentelemetry OpenTelemetry support area:runtime-metrics labels Apr 15, 2026
@link04 link04 marked this pull request as ready for review April 22, 2026 15:36
@link04 link04 requested review from a team as code owners April 22, 2026 15:36
Copy link
Copy Markdown

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

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: 1b582a23e4

ℹ️ 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/OpenTelemetry/Metrics/MetricsRuntime.cs
Comment thread tracer/src/Datadog.Trace/Configuration/TracerSettings.cs Outdated
Copy link
Copy Markdown
Collaborator

@bouwkast bouwkast left a comment

Choose a reason for hiding this comment

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

Haven't gone through everything yet but will pick it up again tomorrow

Comment thread tracer/src/Datadog.Trace/Configuration/TracerSettings.cs Outdated
Comment thread tracer/src/Datadog.Trace/OpenTelemetry/Metrics/MetricsRuntime.cs
Comment thread tracer/src/Datadog.Trace/OpenTelemetry/Metrics/MetricsRuntime.cs Outdated
Copy link
Copy Markdown
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

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

LGTM in general, some relatively minor suggestions and questions in general.

While reviewing this I had a realization - OpenTelemetry themselves add polyfills for many of these... e.g.

https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/5aa6d868/src/OpenTelemetry.Instrumentation.Runtime/RuntimeMetrics.cs#L105C40-L107

What happens if you have the same pollyfilled values, with the same meter and instrument names? 🤔 Do we need to handle that explicitly, or does the runtime handled it? And have you compared our implementation to theirs?

Comment thread tracer/src/Datadog.Trace/Configuration/TracerSettings.cs Outdated
// indicates a counter reset (e.g. process restart). Report currentValue
// as the delta, as if the previous cumulative was 0.
// ObservableUpDownCounter is non-monotonic so negative deltas are expected.
if (delta < 0 && InstrumentType is InstrumentType.ObservableCounter)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a thought, and not strictly related to this PR: Do we need a similar guard somewhere for negative values in InstrumentTrype.Counter too? 🤔 I don't think it needs to be right here (because this method is all about observable counters), but I believe we could have the same wrapping case to handle.

I think we may also need to handle this in our statsd case too - I'll look into it!

// ObservableUpDownCounter is non-monotonic so negative deltas are expected.
if (delta < 0 && InstrumentType is InstrumentType.ObservableCounter)
{
delta = _runningDoubleValue;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had to work this one through to convince myself it's correct, so included here so others don't need to 😅

In an overflow scenario - given that you would have (for example)

  • _runningDoubleValue is small (due to overflow) e.g. 10
  • _lastObservedCumulative is huge e.g. 1,000,000,000,000

Then

  • _delta = _runningDoubleValue - previousCumulative ~-1,000,000,000,000

So we hit this branch and set

  • _delta = _runningDoubleValue = ~10

so LGTM!

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.

Aay thank you for adding this investigation here!

Comment thread tracer/src/Datadog.Trace/OpenTelemetry/Metrics/MetricsRuntime.cs
Comment thread tracer/test/Datadog.Trace.Tests/RuntimeMetrics/RuntimeMetricsMeterTests.cs Outdated
Comment thread tracer/test/Datadog.Trace.Tests/RuntimeMetrics/RuntimeMetricsMeterTests.cs Outdated
Comment thread tracer/test/Datadog.Trace.Tests/RuntimeMetrics/RuntimeMetricsMeterTests.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:opentelemetry OpenTelemetry support area:runtime-metrics docker_image_artifacts Use to label PRs for which you would need a Docker Image created for.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants