Skip to content

Add benchmarks for single-span diagnostic observer for ASP.NET Core#7965

Merged
andrewlock merged 2 commits intomasterfrom
andrew/single-span/4-benchmarks
Jan 13, 2026
Merged

Add benchmarks for single-span diagnostic observer for ASP.NET Core#7965
andrewlock merged 2 commits intomasterfrom
andrew/single-span/4-benchmarks

Conversation

@andrewlock
Copy link
Member

@andrewlock andrewlock commented Dec 17, 2025

Summary of changes

Adds a micro and macro benchmark for the new observer

Reason for change

Want to verify that it has performance benefits

Implementation details

  • Added new scenario for macro
  • Duplicated existing scenario for micro and run. I would like to have had these as the same methods, but the "global" nature of diagnostic observers makes this difficult I think.

Test coverage

I'll manually trigger a run of the macro

Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-842

Part of a stack

@andrewlock andrewlock added the area:benchmarks Benchmarks, throughput tests, Crank, Bombardier, etc label Dec 17, 2025
@andrewlock andrewlock requested review from a team as code owners December 17, 2025 17:21
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from bac154e to 395dce4 Compare December 17, 2025 17:27
@andrewlock andrewlock changed the base branch from andrew/single-span/3-observer to andrew/single-span/5-resource-name December 17, 2025 17:28
@datadog-datadog-prod-us1

This comment has been minimized.

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

dd-trace-dotnet-ci-bot bot commented Dec 17, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (7965) 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
duration78.41 ± (78.18 - 78.61) ms77.50 ± (77.51 - 77.94) ms-1.2%
.NET Framework 4.8 - Bailout
duration81.80 ± (81.60 - 82.01) ms81.55 ± (81.63 - 82.07) ms-0.3%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1088.42 ± (1086.59 - 1092.61) ms1079.86 ± (1079.71 - 1086.42) ms-0.8%
.NET Core 3.1 - Baseline
process.internal_duration_ms23.33 ± (23.28 - 23.38) ms23.58 ± (23.53 - 23.63) ms+1.1%✅⬆️
process.time_to_main_ms88.81 ± (88.61 - 89.01) ms90.24 ± (90.00 - 90.49) ms+1.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.91 ± (10.90 - 10.91) MB10.92 ± (10.91 - 10.92) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms23.43 ± (23.38 - 23.48) ms23.56 ± (23.51 - 23.61) ms+0.6%✅⬆️
process.time_to_main_ms90.79 ± (90.55 - 91.02) ms92.49 ± (92.23 - 92.74) ms+1.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.95 ± (10.95 - 10.95) 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_ms244.25 ± (240.13 - 248.36) ms244.11 ± (240.27 - 247.95) ms-0.1%
process.time_to_main_ms512.46 ± (511.59 - 513.33) ms505.76 ± (504.88 - 506.63) ms-1.3%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.25 ± (48.22 - 48.27) MB48.27 ± (48.25 - 48.30) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.2%
.NET 6 - Baseline
process.internal_duration_ms22.11 ± (22.06 - 22.16) ms22.17 ± (22.12 - 22.23) ms+0.3%✅⬆️
process.time_to_main_ms77.23 ± (77.07 - 77.40) ms77.55 ± (77.37 - 77.74) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 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_ms22.04 ± (21.99 - 22.09) ms22.02 ± (21.97 - 22.07) ms-0.1%
process.time_to_main_ms78.38 ± (78.19 - 78.58) ms78.42 ± (78.26 - 78.58) ms+0.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.70 ± (10.70 - 10.71) MB10.75 ± (10.75 - 10.76) MB+0.4%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms254.49 ± (250.46 - 258.53) ms248.96 ± (244.91 - 253.01) ms-2.2%
process.time_to_main_ms483.95 ± (483.04 - 484.85) ms481.13 ± (480.48 - 481.79) ms-0.6%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.00 ± (48.97 - 49.02) MB49.01 ± (48.99 - 49.03) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.2%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms20.30 ± (20.25 - 20.35) ms20.32 ± (20.28 - 20.36) ms+0.1%✅⬆️
process.time_to_main_ms77.07 ± (76.92 - 77.23) ms76.69 ± (76.51 - 76.87) ms-0.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.65 ± (7.65 - 7.66) 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_ms20.46 ± (20.40 - 20.52) ms20.33 ± (20.28 - 20.37) ms-0.7%
process.time_to_main_ms78.49 ± (78.32 - 78.66) ms77.71 ± (77.53 - 77.89) ms-1.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.69 ± (7.69 - 7.70) MB7.74 ± (7.73 - 7.75) MB+0.6%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms196.64 ± (195.87 - 197.42) ms194.27 ± (193.53 - 195.01) ms-1.2%
process.time_to_main_ms469.44 ± (468.68 - 470.21) ms464.62 ± (463.92 - 465.32) ms-1.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.88 ± (36.84 - 36.92) MB36.87 ± (36.82 - 36.91) MB-0.0%
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)-0.1%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration194.29 ± (194.38 - 195.08) ms195.92 ± (196.04 - 196.95) ms+0.8%✅⬆️
.NET Framework 4.8 - Bailout
duration198.84 ± (198.71 - 199.59) ms199.44 ± (199.37 - 200.32) ms+0.3%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1135.75 ± (1138.03 - 1149.56) ms1140.69 ± (1140.39 - 1149.18) ms+0.4%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms190.89 ± (190.43 - 191.36) ms189.89 ± (189.49 - 190.30) ms-0.5%
process.time_to_main_ms82.03 ± (81.76 - 82.31) ms82.16 ± (81.90 - 82.41) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.05 ± (16.03 - 16.07) MB16.20 ± (16.17 - 16.23) MB+1.0%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+0.5%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms189.33 ± (188.85 - 189.81) ms191.89 ± (191.38 - 192.39) ms+1.4%✅⬆️
process.time_to_main_ms82.68 ± (82.50 - 82.87) ms84.32 ± (84.10 - 84.54) ms+2.0%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.10 ± (16.08 - 16.12) MB16.13 ± (16.10 - 16.15) MB+0.2%✅⬆️
runtime.dotnet.threads.count21 ± (20 - 21)21 ± (21 - 21)+0.5%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms439.03 ± (436.59 - 441.47) ms434.60 ± (431.59 - 437.62) ms-1.0%
process.time_to_main_ms475.82 ± (474.99 - 476.65) ms480.01 ± (479.23 - 480.79) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.66 ± (58.54 - 58.77) MB58.84 ± (58.73 - 58.94) MB+0.3%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 30)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms194.14 ± (193.67 - 194.62) ms197.04 ± (196.58 - 197.49) ms+1.5%✅⬆️
process.time_to_main_ms70.35 ± (70.17 - 70.54) ms72.00 ± (71.79 - 72.21) ms+2.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.38 ± (16.35 - 16.41) MB16.36 ± (16.34 - 16.38) MB-0.1%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.7%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms193.50 ± (193.10 - 193.90) ms196.04 ± (195.63 - 196.46) ms+1.3%✅⬆️
process.time_to_main_ms71.30 ± (71.14 - 71.46) ms72.85 ± (72.64 - 73.06) ms+2.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.42 ± (16.39 - 16.45) MB16.45 ± (16.43 - 16.47) MB+0.2%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+0.5%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms451.70 ± (449.02 - 454.37) ms454.88 ± (452.02 - 457.74) ms+0.7%✅⬆️
process.time_to_main_ms452.91 ± (452.25 - 453.57) ms457.62 ± (456.98 - 458.26) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.56 ± (58.44 - 58.68) MB58.61 ± (58.48 - 58.74) MB+0.1%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms193.66 ± (193.19 - 194.13) ms193.08 ± (192.63 - 193.53) ms-0.3%
process.time_to_main_ms70.39 ± (70.21 - 70.57) ms70.52 ± (70.32 - 70.73) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.71 ± (11.68 - 11.73) MB11.78 ± (11.76 - 11.80) MB+0.6%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)-0.2%
.NET 8 - Bailout
process.internal_duration_ms191.44 ± (191.08 - 191.79) ms193.81 ± (193.35 - 194.28) ms+1.2%✅⬆️
process.time_to_main_ms70.73 ± (70.61 - 70.86) ms71.75 ± (71.58 - 71.93) ms+1.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.75 ± (11.72 - 11.78) MB11.81 ± (11.79 - 11.83) MB+0.5%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.1%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms374.46 ± (373.07 - 375.84) ms373.75 ± (372.14 - 375.37) ms-0.2%
process.time_to_main_ms440.51 ± (439.66 - 441.37) ms443.56 ± (442.51 - 444.61) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed48.27 ± (48.23 - 48.30) MB48.24 ± (48.20 - 48.28) MB-0.0%
runtime.dotnet.threads.count29 ± (28 - 29)29 ± (29 - 29)+0.3%✅⬆️
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 (7965) - mean (78ms)  : 74, 81
    master - mean (78ms)  : 75, 82

    section Bailout
    This PR (7965) - mean (82ms)  : 79, 85
    master - mean (82ms)  : 79, 84

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (1,083ms)  : 1033, 1133
    master - mean (1,090ms)  : 1047, 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 (7965) - mean (121ms)  : 116, 126
    master - mean (119ms)  : 115, 123

    section Bailout
    This PR (7965) - mean (123ms)  : 118, 128
    master - mean (121ms)  : 118, 124

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (791ms)  : 719, 863
    master - mean (797ms)  : 737, 858

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7965) - mean (106ms)  : 103, 110
    master - mean (106ms)  : 103, 109

    section Bailout
    This PR (7965) - mean (107ms)  : 105, 109
    master - mean (107ms)  : 104, 110

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (764ms)  : 695, 834
    master - mean (769ms)  : 691, 847

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

    section Bailout
    This PR (7965) - mean (106ms)  : 103, 109
    master - mean (107ms)  : 104, 109

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (696ms)  : 675, 717
    master - mean (703ms)  : 676, 731

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 (7965) - mean (196ms)  : 191, 202
    master - mean (195ms)  : 191, 199

    section Bailout
    This PR (7965) - mean (200ms)  : 195, 205
    master - mean (199ms)  : 195, 204

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (1,145ms)  : 1082, 1207
    master - mean (1,144ms)  : 1053, 1234

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 (7965) - mean (281ms)  : 276, 287
    master - mean (282ms)  : 271, 293

    section Bailout
    This PR (7965) - mean (285ms)  : 276, 293
    master - mean (281ms)  : 274, 287

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (956ms)  : 899, 1012
    master - mean (943ms)  : 907, 979

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7965) - mean (278ms)  : 268, 287
    master - mean (273ms)  : 267, 280

    section Bailout
    This PR (7965) - mean (278ms)  : 267, 289
    master - mean (273ms)  : 267, 279

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (951ms)  : 901, 1001
    master - mean (936ms)  : 899, 973

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7965) - mean (274ms)  : 267, 281
    master - mean (274ms)  : 266, 282

    section Bailout
    This PR (7965) - mean (276ms)  : 266, 286
    master - mean (272ms)  : 267, 276

    section CallTarget+Inlining+NGEN
    This PR (7965) - mean (850ms)  : 810, 891
    master - mean (847ms)  : 816, 878

Loading

@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from 395dce4 to b70c982 Compare December 18, 2025 09:23
@andrewlock andrewlock requested review from a team as code owners December 18, 2025 09:23
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from c2c2b8c to 37760e4 Compare December 18, 2025 09:23
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from b70c982 to d534f1e Compare December 18, 2025 14:09
@andrewlock andrewlock requested review from a team as code owners December 18, 2025 14:09
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 37760e4 to 65dcd0e Compare December 18, 2025 14:09
andrewlock added a commit that referenced this pull request Dec 23, 2025
## Summary of changes

Adds a `ValueStringBuilder` implementation, based on the one used
internally in the .NET runtime

## Reason for change

- We can stackalloc the `Span<char>`
- It's a bit faster than our existing `StringBuilderCache`
implementation, and in some places that matters.

## Implementation details

- Made in .NET 6 only for simplicity. We _could_ expose it earlier, but
I wanted this for the updated aspnetcore integration, so .NET6+ only for
now is good enough
- It's not without risks in its usage, so we have to be careful about
things like passing it around (i.e. avoid doing that completely, for
safety)
- Uses an array pool backed implementation (again, built into .NET 6)

## Test coverage

Imported the unit tests from the runtime too

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-842

Part of a stack

- #7962 👈
- #7963
- #7964
- #7966
- #7965
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from d534f1e to 199b720 Compare December 23, 2025 12:17
@andrewlock andrewlock requested review from a team as code owners December 23, 2025 12:17
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 65dcd0e to 303a7ac Compare December 23, 2025 12:17
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from 199b720 to acca38c Compare December 23, 2025 14:49
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 303a7ac to 8a6357a Compare December 23, 2025 14:50
andrewlock added a commit that referenced this pull request Dec 24, 2025
## Summary of changes

Small perf tweaks for existing `AspNetCoreDiagnosticObserver`

## Reason for change

While experimenting with single span observer, noticed some (safe)
tweaks we could make to the existing implementation. There are some
other improvements we could make as well, but those are a little
riskier, so may be best to delay them.

## Implementation details

- Use `HttpContext.Items[string]` instead of
`HttpContext.Features.Get<T>` as it's a bit faster
- Make `Tracer`/`Security`/`Iast` inputs readonly, instead of using a
null-coalesce with every access
- Move check outside of `AddHeaderTagsToSpan` given common case is to
avoid the function call

## Test coverage

Covered by existing tests

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-842

Part of a stack


- #7962
- #7963 👈
- #7964
- #7966
- #7965
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from acca38c to 28a568e Compare December 24, 2025 13:29
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 8a6357a to 4fd083f Compare December 24, 2025 13:29
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from 28a568e to 80402b7 Compare December 24, 2025 14:00
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 4fd083f to 5d97960 Compare December 24, 2025 14:00
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from 80402b7 to ac67c63 Compare January 5, 2026 08:19
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 5d97960 to 67ea0dd Compare January 5, 2026 08:19
andrewlock added a commit that referenced this pull request Jan 13, 2026
## Summary of changes

Adds a new `DD_TRACE_SINGLE_SPAN_ASPNETCORE_ENABLED` in which we omit
the MVC span

## Reason for change

- Addresses #4093 and partially #1147
- Omitting the MVC span has perf and some usability benefits in some
cases (See issues above). It _does_ mean a certain amount of less
information, particularly in pipeline re-execution scenarios

## Implementation details

- Add a new, disabled by default,
`DD_TRACE_SINGLE_SPAN_ASPNETCORE_ENABLED` for opting in to the new
behaviour.
- .NET 6+ only for various reasons
- Cloned the original observer, deleted everything related to the MVC
span, and then optimized further based on .NET 6+ and other improvements
we can make

## Test coverage

- Added in-process "integration" tests for the observer (more like unit
tests), which mirror the exisitng.
- Added "full" sample-based integration tests for basically all
scenarios we currently test (IIS in process/out of process / MVC /
minimal APIs / proxy spans etc)
- Added snapshots by copying existing, and then updating, so if you look
at the final commit, you can see the diff, which is basically just
"delete the child span"

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-842

Part of a stack



- #7962
- #7963
- #7964 👈
- #7966
- #7965

I experimented with some other perf improvements, but they didn't
provide a significant improvement, so I reverted:
- Caching the resource name by saving it into the `IEndpointMetadata`
collection. The work to do that was too much, and you _can't_ cache in
some cases anyway so not worth it
- Splitting `WebTags` out to remove the IP headers unless we need them.
They're disabled by default, so it just increase the size of the tags
object, but wasn't a big enough improvement to make the complexity worth
it.
- Tried pooling the `RequestTrackingFeature` objects. This one _may_
actually be worth exploring again later, but I didn't see any
improvement in my testing, as they're just not very big and only last 1
request.

---------

Co-authored-by: Lucas Pimentel <lucas.pimentel@datadoghq.com>
@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 67ea0dd to 2ce366f Compare January 13, 2026 14:51
@andrewlock andrewlock force-pushed the andrew/single-span/4-benchmarks branch from ac67c63 to b7f19f3 Compare January 13, 2026 18:09
@andrewlock andrewlock requested a review from a team as a code owner January 13, 2026 18:09
@andrewlock andrewlock requested review from zacharycmontoya and removed request for a team January 13, 2026 18:09
@andrewlock andrewlock changed the base branch from andrew/single-span/5-resource-name to master January 13, 2026 18:09
@andrewlock andrewlock enabled auto-merge (squash) January 13, 2026 18:09
andrewlock added a commit that referenced this pull request Jan 13, 2026
## Summary of changes

Creates an optimized version of `AspNetCoreResourceNameHelper` for use
by the single-span Diagnostic observer.

## Reason for change

We have the opportunity for a variety of optimizations thanks to not
creating the MVC span, and the fact that we're .NET 6+. We could
potentially include some or all of these optimizations in the existing
observer path, but for safety/simplicity I'd rather keep it isolated for
now, and we can look at expanding it more broadly later

## Implementation details

- Use the `ValueStringBuilder` to build a resource name
- Don't pre-grab MVC route values, wait to see if we have route params
from them first
- Write directly into the builder as `ToLowerInvariant`, instead of
doing an extra ToLower() at the end

## Test coverage

Added unit tests that use the existing data for the other
implementations, to confirm it's identical. It's also covered indirectly
by the integration tests

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-842

Part of a stack


- #7962
- #7963
- #7964
- #7966 👈
- #7965
@andrewlock andrewlock disabled auto-merge January 13, 2026 23:19
@andrewlock andrewlock enabled auto-merge (squash) January 13, 2026 23:20
@andrewlock andrewlock merged commit f1674f6 into master Jan 13, 2026
147 checks passed
@andrewlock andrewlock deleted the andrew/single-span/4-benchmarks branch January 13, 2026 23:21
@github-actions github-actions bot added this to the vNext-v3 milestone Jan 13, 2026
andrewlock added a commit that referenced this pull request Jan 14, 2026
## Summary of changes

Fixes the broken build in the benchmarks

## Reason for change

#7965 broke the benchmark
build for some TFMs. I think the race condition between creating a PR
and running the benchmarks meant we didn't notice the failure,
especially because the run still took 30+ mins because it worked in
_some_ TFMs

## Implementation details

- Ensure we have the dummy benchmark for TFMs that don't support it
- Fix some minor spurious warnings

## Test coverage

This is the test, I'll carefully check the run this time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:benchmarks Benchmarks, throughput tests, Crank, Bombardier, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants