Skip to content

Add a ValueStringBuilder for .NET 6#7962

Merged
andrewlock merged 4 commits intomasterfrom
andrew/single-span/1-valuestringbuilder
Dec 23, 2025
Merged

Add a ValueStringBuilder for .NET 6#7962
andrewlock merged 4 commits intomasterfrom
andrew/single-span/1-valuestringbuilder

Conversation

@andrewlock
Copy link
Member

@andrewlock andrewlock commented Dec 17, 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

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Dec 17, 2025

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

❄️ 1 New flaky test detected

FiresCallbackOnRecheckIfHasChangesToConfig from Datadog.Trace.Tests.Agent.DiscoveryServiceTests (Datadog) (Fix with Cursor)
Expected Volatile.Read(ref notificationCount) to be True because Should make third request to api, but found False.

ℹ️ Info

🧪 All tests passed

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

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

Execution-Time Benchmarks Report ⏱️

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

⚠️ Potential regressions detected

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.13 ± (68.13 - 68.35) ms73.94 ± (73.95 - 74.24) ms+8.5%❌⬆️
.NET Framework 4.8 - Bailout
duration71.94 ± (71.81 - 72.01) ms78.20 ± (78.12 - 78.47) ms+8.7%❌⬆️
Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.13 ± (68.13 - 68.35) ms73.94 ± (73.95 - 74.24) ms+8.5%❌⬆️
.NET Framework 4.8 - Bailout
duration71.94 ± (71.81 - 72.01) ms78.20 ± (78.12 - 78.47) ms+8.7%❌⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1001.47 ± (1007.97 - 1017.63) ms1049.00 ± (1052.06 - 1062.10) ms+4.7%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms21.96 ± (21.94 - 21.99) ms22.82 ± (22.78 - 22.86) ms+3.9%✅⬆️
process.time_to_main_ms78.40 ± (78.23 - 78.56) ms84.43 ± (84.23 - 84.62) ms+7.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.91 ± (10.90 - 10.91) MB10.93 ± (10.92 - 10.94) MB+0.2%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.90 ± (21.88 - 21.92) ms22.73 ± (22.70 - 22.77) ms+3.8%✅⬆️
process.time_to_main_ms79.42 ± (79.33 - 79.52) ms86.10 ± (85.91 - 86.29) ms+8.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.94 ± (10.94 - 10.94) MB10.95 ± (10.95 - 10.96) MB+0.1%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms211.56 ± (209.85 - 213.28) ms221.32 ± (219.68 - 222.96) ms+4.6%✅⬆️
process.time_to_main_ms471.87 ± (471.29 - 472.45) ms495.45 ± (494.67 - 496.24) ms+5.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.05 ± (48.03 - 48.07) MB48.04 ± (48.02 - 48.06) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.0%
.NET 6 - Baseline
process.internal_duration_ms20.59 ± (20.55 - 20.62) ms21.35 ± (21.32 - 21.38) ms+3.7%✅⬆️
process.time_to_main_ms67.89 ± (67.74 - 68.03) ms73.17 ± (73.01 - 73.33) ms+7.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 10.62) MB10.64 ± (10.64 - 10.64) MB+0.2%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.51 ± (20.49 - 20.54) ms21.45 ± (21.40 - 21.50) ms+4.6%✅⬆️
process.time_to_main_ms68.69 ± (68.64 - 68.75) ms74.40 ± (74.24 - 74.55) ms+8.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.68 ± (10.68 - 10.69) MB10.68 ± (10.67 - 10.68) MB-0.1%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms201.55 ± (200.42 - 202.69) ms207.08 ± (206.08 - 208.08) ms+2.7%✅⬆️
process.time_to_main_ms440.63 ± (439.88 - 441.38) ms463.98 ± (463.24 - 464.72) ms+5.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.41 ± (48.36 - 48.47) MB48.52 ± (48.50 - 48.55) MB+0.2%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.1%
.NET 8 - Baseline
process.internal_duration_ms18.80 ± (18.78 - 18.82) ms19.63 ± (19.60 - 19.67) ms+4.4%✅⬆️
process.time_to_main_ms67.01 ± (66.91 - 67.11) ms72.91 ± (72.76 - 73.07) ms+8.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.69 ± (7.68 - 7.70) MB7.68 ± (7.68 - 7.69) MB-0.1%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.76 ± (18.73 - 18.78) ms19.57 ± (19.53 - 19.60) ms+4.3%✅⬆️
process.time_to_main_ms67.95 ± (67.89 - 68.02) ms74.18 ± (74.03 - 74.34) ms+9.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.73 ± (7.72 - 7.74) MB7.73 ± (7.71 - 7.74) MB-0.1%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms178.28 ± (177.29 - 179.26) ms188.58 ± (187.64 - 189.52) ms+5.8%✅⬆️
process.time_to_main_ms421.86 ± (421.31 - 422.41) ms444.40 ± (443.75 - 445.06) ms+5.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.26 ± (36.22 - 36.30) MB36.47 ± (36.42 - 36.51) MB+0.6%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)-0.0%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration193.44 ± (193.61 - 194.53) ms197.92 ± (197.97 - 198.92) ms+2.3%✅⬆️
.NET Framework 4.8 - Bailout
duration196.93 ± (196.66 - 197.21) ms198.22 ± (197.94 - 198.61) ms+0.7%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1108.26 ± (1109.47 - 1116.57) ms1134.90 ± (1134.70 - 1144.31) ms+2.4%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms188.24 ± (187.80 - 188.68) ms191.34 ± (190.81 - 191.86) ms+1.6%✅⬆️
process.time_to_main_ms80.54 ± (80.34 - 80.74) ms82.21 ± (81.95 - 82.47) ms+2.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.11 ± (16.08 - 16.14) MB16.07 ± (16.05 - 16.09) MB-0.2%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.6%
.NET Core 3.1 - Bailout
process.internal_duration_ms187.26 ± (186.95 - 187.57) ms188.89 ± (188.49 - 189.29) ms+0.9%✅⬆️
process.time_to_main_ms81.81 ± (81.68 - 81.94) ms82.74 ± (82.56 - 82.93) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.13 ± (16.10 - 16.16) MB16.19 ± (16.16 - 16.22) MB+0.4%✅⬆️
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)+0.7%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms398.33 ± (395.71 - 400.96) ms402.35 ± (399.54 - 405.15) ms+1.0%✅⬆️
process.time_to_main_ms476.18 ± (475.48 - 476.89) ms481.78 ± (480.89 - 482.68) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.66 ± (58.52 - 58.79) MB58.87 ± (58.76 - 58.98) MB+0.4%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 30)30 ± (29 - 30)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms191.96 ± (191.55 - 192.38) ms195.01 ± (194.59 - 195.44) ms+1.6%✅⬆️
process.time_to_main_ms69.95 ± (69.76 - 70.14) ms70.81 ± (70.61 - 71.01) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed15.96 ± (15.81 - 16.11) MB16.30 ± (16.27 - 16.32) MB+2.1%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 19)19 ± (19 - 19)+4.5%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.01 ± (190.74 - 191.28) ms193.75 ± (193.27 - 194.23) ms+1.4%✅⬆️
process.time_to_main_ms70.83 ± (70.74 - 70.92) ms71.88 ± (71.72 - 72.04) ms+1.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.16 ± (16.03 - 16.30) MB16.26 ± (16.17 - 16.36) MB+0.6%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)20 ± (20 - 20)+3.9%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms412.12 ± (409.68 - 414.56) ms411.92 ± (409.78 - 414.06) ms-0.0%
process.time_to_main_ms444.71 ± (443.94 - 445.49) ms448.90 ± (448.18 - 449.61) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed59.24 ± (59.11 - 59.36) MB59.29 ± (59.18 - 59.41) MB+0.1%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 30)30 ± (29 - 30)+0.2%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms189.55 ± (189.25 - 189.84) ms193.34 ± (192.91 - 193.78) ms+2.0%✅⬆️
process.time_to_main_ms69.08 ± (68.91 - 69.25) ms70.67 ± (70.45 - 70.88) ms+2.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.68 ± (11.66 - 11.71) MB11.65 ± (11.63 - 11.67) MB-0.3%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.6%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms190.20 ± (189.78 - 190.61) ms193.80 ± (193.27 - 194.33) ms+1.9%✅⬆️
process.time_to_main_ms70.35 ± (70.23 - 70.47) ms71.97 ± (71.75 - 72.20) ms+2.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.77 ± (11.74 - 11.80) MB11.72 ± (11.70 - 11.75) MB-0.4%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.2%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms363.94 ± (362.59 - 365.29) ms372.52 ± (371.06 - 373.99) ms+2.4%✅⬆️
process.time_to_main_ms426.63 ± (426.06 - 427.19) ms436.10 ± (435.27 - 436.92) ms+2.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.96 ± (47.93 - 47.99) MB47.97 ± (47.94 - 48.00) MB+0.0%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-0.4%
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 (7962) - mean (74ms)  : 72, 76
    master - mean (68ms)  : 67, 70

    section Bailout
    This PR (7962) - mean (78ms)  : crit, 76, 80
    master - mean (72ms)  : 71, 73

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (1,057ms)  : 985, 1129
    master - mean (1,013ms)  : 941, 1084

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 (7962) - mean (114ms)  : 110, 118
    master - mean (106ms)  : 103, 108

    section Bailout
    This PR (7962) - mean (116ms)  : crit, 114, 118
    master - mean (106ms)  : 105, 107

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (753ms)  : crit, 714, 792
    master - mean (709ms)  : 681, 737

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

    section Bailout
    This PR (7962) - mean (102ms)  : crit, 100, 104
    master - mean (94ms)  : 93, 95

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (699ms)  : 676, 722
    master - mean (669ms)  : 644, 695

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7962) - mean (100ms)  : 98, 103
    master - mean (92ms)  : 90, 94

    section Bailout
    This PR (7962) - mean (101ms)  : crit, 99, 104
    master - mean (93ms)  : 91, 94

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (663ms)  : 644, 682
    master - mean (628ms)  : 615, 642

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 (7962) - mean (198ms)  : 191, 205
    master - mean (194ms)  : 189, 200

    section Bailout
    This PR (7962) - mean (198ms)  : 195, 202
    master - mean (197ms)  : 194, 200

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (1,140ms)  : 1069, 1210
    master - mean (1,113ms)  : 1062, 1164

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 (7962) - mean (282ms)  : 270, 294
    master - mean (277ms)  : 271, 283

    section Bailout
    This PR (7962) - mean (280ms)  : 275, 285
    master - mean (277ms)  : 274, 281

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (920ms)  : 867, 973
    master - mean (907ms)  : 866, 949

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7962) - mean (274ms)  : 267, 281
    master - mean (270ms)  : 265, 276

    section Bailout
    This PR (7962) - mean (274ms)  : 268, 281
    master - mean (270ms)  : 266, 274

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (895ms)  : 846, 945
    master - mean (890ms)  : 845, 934

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7962) - mean (274ms)  : 265, 283
    master - mean (268ms)  : 264, 272

    section Bailout
    This PR (7962) - mean (275ms)  : 263, 288
    master - mean (270ms)  : 265, 275

    section CallTarget+Inlining+NGEN
    This PR (7962) - mean (839ms)  : 806, 871
    master - mean (822ms)  : 803, 842

Loading

@lucaspimentel
Copy link
Member

I thought we had this already, but it was me in a personal project 😅
https://github.com/lucaspimentel/pwsh-prompt/blob/main/src/pwsh-prompt/ValueStringBuilder.cs

I also had a TODO for myself from a long time ago to do this in dd-trace-dotnet, so thanks!

@andrewlock andrewlock merged commit 471dd5c into master Dec 23, 2025
153 checks passed
@andrewlock andrewlock deleted the andrew/single-span/1-valuestringbuilder branch December 23, 2025 10:21
@github-actions github-actions bot added this to the vNext-v3 milestone Dec 23, 2025
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 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 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

type:performance Performance, speed, latency, resource usage (CPU, memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants