Skip to content

Conversation

@andrewlock
Copy link
Member

@andrewlock andrewlock commented Dec 17, 2025

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

@datadog-official
Copy link

datadog-official bot commented Dec 17, 2025

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

🧪 1 Test failed

EnVarShouldWinOverLocal from Datadog.Trace.ClrProfiler.IntegrationTests.HandsOffConfigurationTests (Datadog) (Fix with Cursor)
Expected actualValue to be "true" with a length of 4 because Expected debug to be true, but actual value turned out to be , but "" has a length of 0, differs near "" (index 0).

ℹ️ Info

❄️ No new flaky tests detected

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

@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from c2c2b8c to 37760e4 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/3-observer branch from 5e4ff26 to bdd3a0f Compare December 18, 2025 09:23
@dd-trace-dotnet-ci-bot
Copy link

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

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (7966) 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.41 ± (68.44 - 68.68) ms68.51 ± (68.53 - 68.74) ms+0.1%✅⬆️
.NET Framework 4.8 - Bailout
duration71.91 ± (71.85 - 72.04) ms72.24 ± (72.22 - 72.41) ms+0.5%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1000.78 ± (1005.60 - 1013.60) ms1004.42 ± (1010.95 - 1020.57) ms+0.4%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms21.98 ± (21.95 - 22.01) ms21.93 ± (21.91 - 21.96) ms-0.2%
process.time_to_main_ms78.58 ± (78.45 - 78.71) ms78.45 ± (78.32 - 78.58) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.94 ± (10.93 - 10.94) MB10.90 ± (10.90 - 10.91) MB-0.3%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.91 ± (21.88 - 21.93) ms21.72 ± (21.70 - 21.74) ms-0.9%
process.time_to_main_ms79.71 ± (79.63 - 79.79) ms79.82 ± (79.74 - 79.90) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.94 ± (10.94 - 10.95) MB10.94 ± (10.94 - 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_ms212.83 ± (210.87 - 214.79) ms247.81 ± (243.68 - 251.93) ms+16.4%✅⬆️
process.time_to_main_ms471.91 ± (471.44 - 472.37) ms472.33 ± (471.89 - 472.77) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.01 ± (47.99 - 48.04) MB48.18 ± (48.16 - 48.20) MB+0.3%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+1.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms20.65 ± (20.62 - 20.67) ms20.60 ± (20.57 - 20.62) ms-0.2%
process.time_to_main_ms67.76 ± (67.65 - 67.87) ms67.92 ± (67.82 - 68.02) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.61 ± (10.61 - 10.61) MB10.62 ± (10.62 - 10.62) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.62 ± (20.59 - 20.64) ms20.55 ± (20.52 - 20.57) ms-0.3%
process.time_to_main_ms68.81 ± (68.75 - 68.86) ms68.86 ± (68.80 - 68.91) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.66 ± (10.65 - 10.66) MB10.66 ± (10.66 - 10.66) MB+0.0%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms200.57 ± (199.38 - 201.76) ms246.60 ± (244.49 - 248.71) ms+22.9%✅⬆️
process.time_to_main_ms440.19 ± (439.55 - 440.84) ms444.30 ± (443.74 - 444.86) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.38 ± (48.32 - 48.44) MB48.69 ± (48.65 - 48.72) MB+0.6%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.2%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms18.77 ± (18.74 - 18.80) ms18.93 ± (18.89 - 18.96) ms+0.8%✅⬆️
process.time_to_main_ms66.84 ± (66.72 - 66.96) ms67.55 ± (67.43 - 67.68) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.67 ± (7.67 - 7.68) MB7.65 ± (7.64 - 7.66) MB-0.3%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.78 ± (18.75 - 18.81) ms18.88 ± (18.85 - 18.90) ms+0.5%✅⬆️
process.time_to_main_ms68.01 ± (67.94 - 68.07) ms68.26 ± (68.19 - 68.33) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.74 ± (7.73 - 7.75) MB7.71 ± (7.70 - 7.71) MB-0.4%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms177.45 ± (176.49 - 178.41) ms180.01 ± (179.09 - 180.94) ms+1.4%✅⬆️
process.time_to_main_ms422.60 ± (422.00 - 423.20) ms428.73 ± (428.05 - 429.41) ms+1.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.21 ± (36.18 - 36.24) MB36.32 ± (36.30 - 36.35) MB+0.3%✅⬆️
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
duration193.42 ± (193.20 - 194.00) ms193.64 ± (193.77 - 194.68) ms+0.1%✅⬆️
.NET Framework 4.8 - Bailout
duration196.91 ± (196.67 - 197.22) ms196.81 ± (196.73 - 197.25) ms-0.1%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1111.05 ± (1110.93 - 1117.37) ms1113.26 ± (1116.54 - 1125.29) ms+0.2%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms187.32 ± (186.98 - 187.67) ms188.15 ± (187.79 - 188.50) ms+0.4%✅⬆️
process.time_to_main_ms80.65 ± (80.43 - 80.88) ms80.64 ± (80.47 - 80.82) ms-0.0%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.04 ± (16.01 - 16.06) MB16.07 ± (16.04 - 16.10) MB+0.2%✅⬆️
runtime.dotnet.threads.count20 ± (19 - 20)20 ± (20 - 20)+0.8%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms186.92 ± (186.60 - 187.24) ms188.23 ± (187.86 - 188.60) ms+0.7%✅⬆️
process.time_to_main_ms81.99 ± (81.85 - 82.14) ms82.61 ± (82.44 - 82.79) ms+0.8%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.08 ± (16.00 - 16.16) MB16.10 ± (16.07 - 16.13) MB+0.1%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)21 ± (21 - 21)+2.2%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms397.62 ± (395.20 - 400.05) ms425.60 ± (422.35 - 428.84) ms+7.0%✅⬆️
process.time_to_main_ms477.19 ± (476.46 - 477.92) ms478.40 ± (477.71 - 479.09) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.75 ± (58.62 - 58.88) MB58.59 ± (58.48 - 58.71) MB-0.3%
runtime.dotnet.threads.count29 ± (29 - 30)29 ± (29 - 30)-0.0%
.NET 6 - Baseline
process.internal_duration_ms192.19 ± (191.83 - 192.56) ms192.61 ± (192.30 - 192.92) ms+0.2%✅⬆️
process.time_to_main_ms70.01 ± (69.83 - 70.18) ms70.37 ± (70.21 - 70.53) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.15 ± (16.02 - 16.28) MB16.30 ± (16.21 - 16.39) MB+0.9%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 19)19 ± (19 - 19)+2.2%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.32 ± (191.03 - 191.61) ms191.88 ± (191.62 - 192.13) ms+0.3%✅⬆️
process.time_to_main_ms70.77 ± (70.67 - 70.87) ms71.26 ± (71.17 - 71.36) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.17 ± (16.03 - 16.31) MB16.40 ± (16.34 - 16.47) MB+1.5%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)20 ± (20 - 20)+4.2%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms412.62 ± (410.09 - 415.14) ms457.30 ± (455.48 - 459.12) ms+10.8%✅⬆️
process.time_to_main_ms449.24 ± (448.43 - 450.05) ms450.49 ± (449.85 - 451.14) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.98 ± (58.85 - 59.12) MB58.22 ± (58.10 - 58.33) MB-1.3%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms189.91 ± (189.51 - 190.31) ms190.69 ± (190.30 - 191.08) ms+0.4%✅⬆️
process.time_to_main_ms69.45 ± (69.24 - 69.65) ms69.72 ± (69.55 - 69.89) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.78 ± (11.76 - 11.81) MB11.78 ± (11.76 - 11.80) MB-0.0%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.2%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms190.00 ± (189.73 - 190.27) ms190.25 ± (189.99 - 190.52) ms+0.1%✅⬆️
process.time_to_main_ms70.53 ± (70.44 - 70.62) ms71.02 ± (70.89 - 71.15) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.85 ± (11.82 - 11.88) MB11.86 ± (11.83 - 11.89) MB+0.1%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.6%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms364.31 ± (362.84 - 365.78) ms363.51 ± (361.98 - 365.05) ms-0.2%
process.time_to_main_ms429.58 ± (429.01 - 430.16) ms432.74 ± (431.87 - 433.60) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed48.00 ± (47.98 - 48.03) MB47.92 ± (47.88 - 47.96) MB-0.2%
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.0%✅⬆️
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 (7966) - mean (69ms)  : 67, 70
    master - mean (69ms)  : 67, 70

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

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (1,016ms)  : 947, 1085
    master - mean (1,010ms)  : 953, 1066

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 (7966) - mean (106ms)  : 104, 108
    master - mean (106ms)  : 104, 108

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

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (741ms)  : 667, 814
    master - mean (715ms)  : 670, 760

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

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

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (713ms)  : crit, 665, 761
    master - mean (667ms)  : 646, 689

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

    section Bailout
    This PR (7966) - mean (93ms)  : 92, 94
    master - mean (93ms)  : 91, 94

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (637ms)  : 621, 652
    master - mean (629ms)  : 616, 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 (7966) - mean (194ms)  : 189, 199
    master - mean (194ms)  : 190, 197

    section Bailout
    This PR (7966) - mean (197ms)  : 195, 199
    master - mean (197ms)  : 194, 200

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (1,121ms)  : 1058, 1184
    master - mean (1,114ms)  : 1069, 1160

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 (7966) - mean (277ms)  : 272, 282
    master - mean (277ms)  : 272, 281

    section Bailout
    This PR (7966) - mean (279ms)  : 275, 284
    master - mean (277ms)  : 273, 281

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (932ms)  : 881, 982
    master - mean (916ms)  : 868, 963

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7966) - mean (272ms)  : 268, 276
    master - mean (270ms)  : 265, 275

    section Bailout
    This PR (7966) - mean (271ms)  : 269, 274
    master - mean (270ms)  : 267, 273

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (940ms)  : 903, 976
    master - mean (895ms)  : 849, 940

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7966) - mean (270ms)  : 264, 277
    master - mean (269ms)  : 263, 275

    section Bailout
    This PR (7966) - mean (271ms)  : 267, 274
    master - mean (270ms)  : 265, 275

    section CallTarget+Inlining+NGEN
    This PR (7966) - mean (830ms)  : 813, 846
    master - mean (825ms)  : 797, 852

Loading

@andrewlock andrewlock force-pushed the andrew/single-span/5-resource-name branch from 37760e4 to 65dcd0e 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/3-observer branch from bdd3a0f to 88205c8 Compare December 18, 2025 14:09
}
else
{
sb.Append(parameterName);
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT: Previously we were not appending the parameterName to the route name but write an empty value if no value was found. This change seems reasonable, but still worth to note the different which, I assume, is intended.

Copy link
Collaborator

@NachoEchevarria NachoEchevarria left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants