Skip to content

Add a new single-span diagnostic observer for ASP.NET Core#7964

Merged
andrewlock merged 11 commits intomasterfrom
andrew/single-span/3-observer
Jan 13, 2026
Merged

Add a new single-span diagnostic observer for ASP.NET Core#7964
andrewlock merged 11 commits intomasterfrom
andrew/single-span/3-observer

Conversation

@andrewlock
Copy link
Member

@andrewlock andrewlock commented Dec 17, 2025

Summary of changes

Adds a new DD_TRACE_SINGLE_SPAN_ASPNETCORE_ENABLED in which we omit the MVC span

Reason for change

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

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.

@datadog-official
Copy link

datadog-official bot commented Dec 17, 2025

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

❄️ 1 New flaky test detected

AfterInitialSuccessThenMultipleFailures_SinkIsTemporarilyDisabled from Datadog.Trace.Tests.Logging.DirectSubmission.Sink.PeriodicBatching.BatchingSinkTests (Datadog) (Fix with Cursor)
Expected sink.Batches.Count to be 11, but found 12 (difference of 1).

ℹ️ Info

🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: de692e8 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@andrewlock andrewlock force-pushed the andrew/single-span/3-observer branch 2 times, most recently from bdd3a0f to 88205c8 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
@dd-trace-dotnet-ci-bot
Copy link

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

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (7964) 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
duration68.45 ± (68.44 - 68.77) ms68.30 ± (68.30 - 68.51) ms-0.2%
.NET Framework 4.8 - Bailout
duration72.15 ± (72.09 - 72.32) ms72.22 ± (72.20 - 72.43) ms+0.1%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1002.55 ± (1002.47 - 1007.48) ms1004.10 ± (1008.09 - 1016.16) ms+0.2%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms21.92 ± (21.90 - 21.95) ms21.84 ± (21.81 - 21.88) ms-0.4%
process.time_to_main_ms78.55 ± (78.40 - 78.70) ms78.94 ± (78.77 - 79.12) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.90 ± (10.90 - 10.91) MB10.91 ± (10.91 - 10.91) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.84 ± (21.82 - 21.86) ms21.76 ± (21.73 - 21.78) ms-0.4%
process.time_to_main_ms79.76 ± (79.66 - 79.86) ms80.02 ± (79.93 - 80.11) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.95 ± (10.94 - 10.95) MB10.94 ± (10.93 - 10.94) MB-0.1%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms253.13 ± (249.54 - 256.72) ms251.43 ± (247.75 - 255.10) ms-0.7%
process.time_to_main_ms470.65 ± (470.20 - 471.10) ms472.45 ± (471.96 - 472.93) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.17 ± (48.15 - 48.20) MB48.27 ± (48.24 - 48.29) MB+0.2%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.3%
.NET 6 - Baseline
process.internal_duration_ms20.70 ± (20.67 - 20.74) ms20.54 ± (20.51 - 20.58) ms-0.8%
process.time_to_main_ms68.20 ± (68.09 - 68.32) ms68.07 ± (67.96 - 68.19) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.63 ± (10.62 - 10.63) MB10.63 ± (10.63 - 10.63) MB+0.0%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.57 ± (20.56 - 20.59) ms20.51 ± (20.49 - 20.53) ms-0.3%
process.time_to_main_ms69.01 ± (68.95 - 69.06) ms68.89 ± (68.83 - 68.95) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.68 ± (10.67 - 10.68) MB10.74 ± (10.73 - 10.74) MB+0.6%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms246.33 ± (244.95 - 247.71) ms244.90 ± (242.98 - 246.81) ms-0.6%
process.time_to_main_ms438.75 ± (438.23 - 439.26) ms441.57 ± (441.14 - 441.99) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.69 ± (48.66 - 48.72) MB48.74 ± (48.71 - 48.77) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.0%
.NET 8 - Baseline
process.internal_duration_ms18.82 ± (18.79 - 18.84) ms18.79 ± (18.76 - 18.81) ms-0.2%
process.time_to_main_ms66.86 ± (66.76 - 66.96) ms67.33 ± (67.22 - 67.44) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.67 ± (7.66 - 7.67) MB7.67 ± (7.66 - 7.67) MB-0.0%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.79 ± (18.77 - 18.81) ms18.87 ± (18.85 - 18.90) ms+0.4%✅⬆️
process.time_to_main_ms68.03 ± (67.97 - 68.08) ms68.41 ± (68.36 - 68.46) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.72 - 7.73) MB7.72 ± (7.71 - 7.74) MB-0.0%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms178.85 ± (177.88 - 179.82) ms178.09 ± (177.05 - 179.13) ms-0.4%
process.time_to_main_ms425.76 ± (425.02 - 426.50) ms425.39 ± (424.70 - 426.07) ms-0.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.32 ± (36.29 - 36.35) MB36.31 ± (36.27 - 36.34) MB-0.0%
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)-0.3%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration192.53 ± (192.39 - 193.16) ms191.76 ± (192.00 - 192.91) ms-0.4%
.NET Framework 4.8 - Bailout
duration195.57 ± (195.23 - 195.74) ms195.43 ± (195.44 - 196.12) ms-0.1%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1098.13 ± (1100.47 - 1107.22) ms1104.82 ± (1105.92 - 1112.99) ms+0.6%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms186.34 ± (186.02 - 186.66) ms187.77 ± (187.37 - 188.18) ms+0.8%✅⬆️
process.time_to_main_ms80.01 ± (79.79 - 80.22) ms80.27 ± (80.05 - 80.50) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.09 ± (16.07 - 16.11) MB16.19 ± (16.17 - 16.22) MB+0.6%✅⬆️
runtime.dotnet.threads.count20 ± (19 - 20)20 ± (20 - 20)+0.2%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms186.96 ± (186.67 - 187.26) ms187.13 ± (186.74 - 187.53) ms+0.1%✅⬆️
process.time_to_main_ms81.58 ± (81.45 - 81.72) ms81.92 ± (81.73 - 82.10) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.13 ± (16.10 - 16.16) MB16.20 ± (16.17 - 16.23) MB+0.5%✅⬆️
runtime.dotnet.threads.count21 ± (20 - 21)21 ± (21 - 21)+0.9%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms428.43 ± (425.42 - 431.45) ms429.24 ± (426.35 - 432.13) ms+0.2%✅⬆️
process.time_to_main_ms470.39 ± (469.94 - 470.85) ms473.43 ± (472.89 - 473.97) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.26 ± (58.13 - 58.39) MB58.67 ± (58.56 - 58.78) MB+0.7%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 30)29 ± (29 - 30)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms190.41 ± (190.05 - 190.77) ms191.81 ± (191.41 - 192.20) ms+0.7%✅⬆️
process.time_to_main_ms69.23 ± (69.07 - 69.38) ms69.73 ± (69.55 - 69.92) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.08 ± (15.94 - 16.22) MB16.11 ± (15.97 - 16.24) MB+0.2%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)19 ± (19 - 19)+3.7%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms189.57 ± (189.26 - 189.87) ms190.04 ± (189.77 - 190.32) ms+0.2%✅⬆️
process.time_to_main_ms70.44 ± (70.35 - 70.54) ms70.36 ± (70.26 - 70.46) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed15.91 ± (15.75 - 16.08) MB15.99 ± (15.82 - 16.16) MB+0.5%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.1%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms453.87 ± (451.99 - 455.74) ms455.11 ± (453.27 - 456.95) ms+0.3%✅⬆️
process.time_to_main_ms442.40 ± (441.99 - 442.80) ms444.69 ± (444.05 - 445.32) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.34 ± (58.23 - 58.44) MB58.36 ± (58.26 - 58.46) MB+0.0%✅⬆️
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.0%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms188.59 ± (188.28 - 188.91) ms192.84 ± (192.39 - 193.30) ms+2.3%✅⬆️
process.time_to_main_ms68.92 ± (68.73 - 69.10) ms70.13 ± (69.94 - 70.32) ms+1.8%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.73 ± (11.70 - 11.76) MB11.77 ± (11.74 - 11.79) MB+0.3%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.1%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms187.60 ± (187.40 - 187.79) ms192.64 ± (192.12 - 193.16) ms+2.7%✅⬆️
process.time_to_main_ms69.94 ± (69.86 - 70.01) ms71.45 ± (71.28 - 71.63) ms+2.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.78 ± (11.73 - 11.84) MB11.81 ± (11.79 - 11.83) MB+0.2%✅⬆️
runtime.dotnet.threads.count19 ± (18 - 19)19 ± (19 - 19)+2.5%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms361.86 ± (360.20 - 363.51) ms365.70 ± (364.38 - 367.03) ms+1.1%✅⬆️
process.time_to_main_ms426.42 ± (425.81 - 427.02) ms430.42 ± (429.63 - 431.22) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.90 ± (47.86 - 47.93) MB47.99 ± (47.96 - 48.01) MB+0.2%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-0.5%
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 (7964) - mean (68ms)  : 67, 70
    master - mean (69ms)  : 66, 71

    section Bailout
    This PR (7964) - mean (72ms)  : 71, 73
    master - mean (72ms)  : 71, 73

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (1,012ms)  : 954, 1071
    master - mean (1,005ms)  : 969, 1041

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 (7964) - mean (106ms)  : 103, 109
    master - mean (106ms)  : 102, 110

    section Bailout
    This PR (7964) - mean (107ms)  : 106, 108
    master - mean (107ms)  : 105, 108

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (746ms)  : 689, 803
    master - mean (744ms)  : 687, 802

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

    section Bailout
    This PR (7964) - mean (94ms)  : 93, 95
    master - mean (94ms)  : 93, 95

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (711ms)  : 683, 740
    master - mean (707ms)  : 676, 738

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

    section Bailout
    This PR (7964) - mean (93ms)  : 92, 95
    master - mean (93ms)  : 92, 94

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (631ms)  : 617, 644
    master - mean (633ms)  : 617, 649

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 (7964) - mean (192ms)  : 188, 197
    master - mean (193ms)  : 189, 197

    section Bailout
    This PR (7964) - mean (196ms)  : 192, 199
    master - mean (195ms)  : 193, 198

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (1,109ms)  : 1059, 1160
    master - mean (1,104ms)  : 1055, 1153

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 (7964) - mean (276ms)  : 270, 282
    master - mean (274ms)  : 269, 280

    section Bailout
    This PR (7964) - mean (277ms)  : 272, 282
    master - mean (276ms)  : 273, 280

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (931ms)  : 891, 970
    master - mean (926ms)  : 880, 972

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7964) - mean (270ms)  : 264, 276
    master - mean (268ms)  : 263, 273

    section Bailout
    This PR (7964) - mean (269ms)  : 265, 272
    master - mean (268ms)  : 264, 272

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (928ms)  : 890, 966
    master - mean (926ms)  : 895, 956

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7964) - mean (273ms)  : 264, 281
    master - mean (267ms)  : 262, 272

    section Bailout
    This PR (7964) - mean (274ms)  : 264, 283
    master - mean (267ms)  : 264, 270

    section CallTarget+Inlining+NGEN
    This PR (7964) - mean (826ms)  : 802, 851
    master - mean (820ms)  : 802, 838

Loading

@andrewlock andrewlock force-pushed the andrew/single-span/3-observer branch from 00fe314 to e8369e2 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/2-minor-fixes branch from bc14e1f to accaca2 Compare December 23, 2025 12:17
@pr-commenter
Copy link

pr-commenter bot commented Dec 23, 2025

Benchmarks

Benchmark execution time: 2026-01-05 09:18:46

Comparing candidate commit de692e8 in PR branch andrew/single-span/3-observer with baseline commit 0df2540 in branch master.

Found 6 performance improvements and 3 performance regressions! Performance is the same for 159 metrics, 18 unstable metrics.

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

  • 🟥 execution_time [+15.845ms; +21.575ms] or [+7.817%; +10.644%]

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

  • 🟩 execution_time [-17.116ms; -10.652ms] or [-8.095%; -5.038%]

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

  • 🟩 execution_time [-20.827ms; -15.522ms] or [-9.980%; -7.437%]

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

  • 🟩 execution_time [-22.055ms; -21.938ms] or [-10.867%; -10.809%]

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

  • 🟥 execution_time [+23.706ms; +24.079ms] or [+13.315%; +13.524%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟩 execution_time [-32.956ms; -27.113ms] or [-13.734%; -11.299%]

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

  • 🟩 execution_time [-1.532ms; -1.151ms] or [-39.270%; -29.503%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟩 execution_time [-11.549ms; -11.208ms] or [-5.710%; -5.541%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472

  • 🟥 throughput [-51515.982op/s; -50749.030op/s] or [-5.639%; -5.555%]

@andrewlock andrewlock force-pushed the andrew/single-span/3-observer branch from e8369e2 to bb0fb1b Compare December 23, 2025 14:50
@andrewlock andrewlock force-pushed the andrew/single-span/2-minor-fixes branch from accaca2 to 383da45 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
Base automatically changed from andrew/single-span/2-minor-fixes to master December 24, 2025 13:25
@andrewlock andrewlock force-pushed the andrew/single-span/3-observer branch 2 times, most recently from a356866 to 04d208f Compare December 24, 2025 14:00
@andrewlock andrewlock force-pushed the andrew/single-span/3-observer branch from 04d208f to de692e8 Compare January 5, 2026 08:19
Copy link
Contributor

@GreenMatan GreenMatan left a comment

Choose a reason for hiding this comment

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

Left a comment regarding code duplication

@andrewlock andrewlock merged commit d49f790 into master Jan 13, 2026
154 checks passed
@andrewlock andrewlock deleted the andrew/single-span/3-observer branch January 13, 2026 14:47
@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 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 added a commit that referenced this pull request Jan 13, 2026
…7965)

## 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



- #7962
- #7963
- #7964
- #7966
- #7965 👈
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) type:new-feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants