Skip to content

Conversation

@lucaspimentel
Copy link
Member

@lucaspimentel lucaspimentel commented Oct 6, 2025

Summary of changes

Fixes incorrect span parenting in isolated Azure Functions when using ASP.NET Core integration. Worker process spans are now correctly parented to the HTTP client span that makes the host→worker call, instead of being incorrectly parented to the root host span.

Reason for change

When using isolated Azure Functions with ASP.NET Core integration and HTTP proxying enabled, spans created in the worker process were being parented to the wrong span, causing disconnected or incorrectly structured traces. This made it difficult to understand the complete request flow and latency attribution.

Current (incorrect) behavior:

ROOT: azure_functions.invoke: GET /api/httptest [HOST]
  ├─ http.request: GET localhost:40521/api/HttpTest [HOST → WORKER]
  └─ azure_functions.invoke: Http HttpTest [WORKER] ❌ wrong parent
      └─ (worker child spans)

Fixed (correct) behavior:

ROOT: azure_functions.invoke: GET /api/httptest [HOST]
  └─ http.request: GET localhost:40521/api/HttpTest [HOST → WORKER]
      └─ azure_functions.invoke: Http HttpTest [WORKER] ✅ correct parent
          └─ (worker child spans)

Implementation details

The issue was in GrpcMessageConversionExtensionsToRpcHttpIntegration.cs. When HTTP proxying is enabled:

  1. The host process creates an HTTP client call to the worker process
  2. HTTP client instrumentation automatically creates a span and propagates context in HTTP headers
  3. However, we were also injecting the Azure Functions host span context into the gRPC message
  4. The worker received both contexts and preferred the gRPC context
  5. This caused worker spans to be parented to the root host span instead of the HTTP call span

Fix: When isHttpProxying && !requiresRouteParameters, skip gRPC context injection entirely and let HTTP client instrumentation handle context propagation naturally.

This preserves existing behavior for non-proxying scenarios (timer triggers, non-ASP.NET Core HTTP triggers) while fixing the proxying case.

Test coverage

TODO

  • test http triggers with ASP.NET Core integration
  • test http triggers without ASP.NET Core integration
  • test in-process functions
  • test incoming propagation headers

Other details

Fixes APMSVLS-58

Documentation:

  • Added comprehensive documentation in docs/development/AzureFunctions.md including:
    • Problem description and root cause analysis
    • Visual comparison of incorrect vs correct span hierarchies
    • Technical details about HTTP proxying flow
    • Step-by-step reproduction instructions
    • Files involved in the fix

@lucaspimentel lucaspimentel changed the title Fix span parenting for isolated Azure Functions with ASP.NET Core integration [Azure Functions] Fix span parenting for isolated functions with ASP.NET Core integration Oct 6, 2025
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Oct 6, 2025

⚠️ Tests

⚠️ Warnings

🧪 21 Tests failed

AzureFunctionsTests+IsolatedRuntimeV4AspNetCore.SubmitsTraces from Datadog.Trace.ClrProfiler.IntegrationTests (Datadog)
Expected spans.Count to be 26, but found 31 (difference of 5).
AzureFunctionsTests+IsolatedRuntimeV4AspNetCore.SubmitsTraces from Datadog.Trace.ClrProfiler.IntegrationTests (Datadog)
Expected spans.Count to be 26, but found 31 (difference of 5).
AzureFunctionsTests+IsolatedRuntimeV4AspNetCore.SubmitsTraces from Datadog.Trace.ClrProfiler.IntegrationTests (Datadog)
Expected spans.Count to be 26, but found 31 (difference of 5).
View all

ℹ️ Info

❄️ No new flaky tests detected

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

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

dd-trace-dotnet-ci-bot bot commented Oct 6, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (7628) 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
duration76.58 ± (76.88 - 77.83) ms77.66 ± (77.64 - 78.70) ms+1.4%✅⬆️
.NET Framework 4.8 - Bailout
duration79.89 ± (79.75 - 80.39) ms79.80 ± (80.14 - 81.13) ms-0.1%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1069.02 ± (1074.30 - 1086.47) ms1090.58 ± (1091.13 - 1105.89) ms+2.0%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms23.11 ± (23.02 - 23.19) ms23.06 ± (22.99 - 23.14) ms-0.2%
process.time_to_main_ms88.63 ± (88.10 - 89.16) ms88.78 ± (88.39 - 89.18) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.92 ± (10.92 - 10.92) MB10.93 ± (10.92 - 10.93) MB+0.0%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms23.13 ± (23.05 - 23.20) ms23.13 ± (23.06 - 23.21) ms+0.0%✅⬆️
process.time_to_main_ms90.91 ± (90.48 - 91.35) ms91.74 ± (91.26 - 92.23) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.96 ± (10.96 - 10.97) MB10.96 ± (10.96 - 10.97) MB-0.0%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms224.13 ± (222.61 - 225.64) ms225.55 ± (224.26 - 226.83) ms+0.6%✅⬆️
process.time_to_main_ms508.07 ± (506.50 - 509.65) ms511.66 ± (510.14 - 513.19) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed47.75 ± (47.73 - 47.77) MB47.78 ± (47.76 - 47.80) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.2%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms22.21 ± (22.11 - 22.30) ms22.17 ± (22.06 - 22.28) ms-0.2%
process.time_to_main_ms79.15 ± (78.68 - 79.62) ms79.20 ± (78.72 - 79.68) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.60 ± (10.60 - 10.60) MB10.63 ± (10.63 - 10.63) MB+0.3%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.99 ± (21.91 - 22.07) ms22.02 ± (21.94 - 22.09) ms+0.1%✅⬆️
process.time_to_main_ms79.90 ± (79.44 - 80.36) ms80.34 ± (79.94 - 80.75) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.64 ± (10.64 - 10.65) MB10.68 ± (10.68 - 10.69) MB+0.4%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms215.28 ± (213.75 - 216.81) ms212.91 ± (211.37 - 214.45) ms-1.1%
process.time_to_main_ms479.77 ± (478.42 - 481.12) ms477.01 ± (475.57 - 478.45) ms-0.6%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.00 ± (47.97 - 48.02) MB48.12 ± (48.10 - 48.15) MB+0.3%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.0%
.NET 8 - Baseline
process.internal_duration_ms20.18 ± (20.10 - 20.27) ms20.11 ± (20.03 - 20.19) ms-0.3%
process.time_to_main_ms77.50 ± (77.08 - 77.92) ms77.55 ± (77.09 - 78.01) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.67 ± (7.66 - 7.67) MB7.64 ± (7.63 - 7.65) MB-0.3%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms20.18 ± (20.10 - 20.26) ms20.13 ± (20.05 - 20.21) ms-0.2%
process.time_to_main_ms79.10 ± (78.64 - 79.56) ms77.73 ± (77.32 - 78.14) ms-1.7%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.71 - 7.73) MB7.69 ± (7.69 - 7.70) MB-0.3%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms195.31 ± (194.33 - 196.29) ms194.12 ± (192.96 - 195.28) ms-0.6%
process.time_to_main_ms469.22 ± (467.79 - 470.65) ms463.52 ± (461.44 - 465.61) ms-1.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.47 ± (36.43 - 36.51) MB36.46 ± (36.42 - 36.50) MB-0.0%
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
duration194.66 ± (194.42 - 195.26) ms200.30 ± (199.97 - 200.95) ms+2.9%✅⬆️
.NET Framework 4.8 - Bailout
duration199.71 ± (199.41 - 200.23) ms200.54 ± (200.36 - 201.25) ms+0.4%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1116.86 ± (1121.99 - 1131.74) ms1116.83 ± (1120.57 - 1129.37) ms-0.0%
.NET Core 3.1 - Baseline
process.internal_duration_ms189.21 ± (188.79 - 189.63) ms190.76 ± (190.33 - 191.18) ms+0.8%✅⬆️
process.time_to_main_ms81.67 ± (81.41 - 81.92) ms82.32 ± (82.05 - 82.59) ms+0.8%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.12 ± (16.09 - 16.16) MB16.09 ± (16.06 - 16.11) MB-0.2%
runtime.dotnet.threads.count20 ± (19 - 20)20 ± (20 - 20)+0.2%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms189.91 ± (189.49 - 190.33) ms192.45 ± (191.98 - 192.92) ms+1.3%✅⬆️
process.time_to_main_ms83.39 ± (83.18 - 83.60) ms84.26 ± (84.00 - 84.52) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.15 ± (16.13 - 16.17) MB16.12 ± (16.10 - 16.14) MB-0.2%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (20 - 21)-0.2%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms399.61 ± (397.31 - 401.92) ms403.51 ± (400.01 - 407.02) ms+1.0%✅⬆️
process.time_to_main_ms478.43 ± (477.43 - 479.44) ms480.07 ± (478.66 - 481.48) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.71 ± (58.60 - 58.83) MB58.86 ± (58.75 - 58.97) MB+0.3%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)30 ± (29 - 30)+0.2%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms192.99 ± (192.67 - 193.30) ms196.92 ± (196.43 - 197.40) ms+2.0%✅⬆️
process.time_to_main_ms70.44 ± (70.28 - 70.61) ms71.93 ± (71.71 - 72.16) ms+2.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.36 ± (16.29 - 16.44) MB16.35 ± (16.33 - 16.37) MB-0.1%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+1.6%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.87 ± (191.63 - 192.12) ms196.22 ± (195.72 - 196.72) ms+2.3%✅⬆️
process.time_to_main_ms71.55 ± (71.44 - 71.66) ms72.58 ± (72.37 - 72.79) ms+1.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.45 ± (16.37 - 16.53) MB16.40 ± (16.38 - 16.43) MB-0.3%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+1.7%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms418.29 ± (415.63 - 420.96) ms423.68 ± (420.14 - 427.22) ms+1.3%✅⬆️
process.time_to_main_ms445.57 ± (444.83 - 446.30) ms445.87 ± (445.13 - 446.61) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed59.16 ± (59.04 - 59.27) MB58.75 ± (58.61 - 58.89) MB-0.7%
runtime.dotnet.threads.count30 ± (29 - 30)30 ± (29 - 30)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms191.55 ± (191.12 - 191.98) ms191.83 ± (191.42 - 192.24) ms+0.1%✅⬆️
process.time_to_main_ms70.41 ± (70.24 - 70.59) ms70.38 ± (70.17 - 70.59) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.80 ± (11.78 - 11.83) MB11.77 ± (11.74 - 11.80) MB-0.3%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.1%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms191.44 ± (191.10 - 191.78) ms193.19 ± (192.75 - 193.63) ms+0.9%✅⬆️
process.time_to_main_ms71.39 ± (71.24 - 71.53) ms71.95 ± (71.77 - 72.13) ms+0.8%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.87 ± (11.84 - 11.90) MB11.76 ± (11.74 - 11.78) MB-0.9%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.5%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms367.00 ± (365.53 - 368.48) ms367.25 ± (365.75 - 368.75) ms+0.1%✅⬆️
process.time_to_main_ms433.07 ± (432.47 - 433.66) ms432.79 ± (432.20 - 433.38) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.85 ± (47.83 - 47.88) MB47.89 ± (47.86 - 47.92) MB+0.1%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+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 (7628) - mean (78ms)  : 70, 86
    master - mean (77ms)  : 71, 84

    section Bailout
    This PR (7628) - mean (81ms)  : 73, 88
    master - mean (80ms)  : 75, 85

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (1,099ms)  : 984, 1213
    master - mean (1,080ms)  : 989, 1172

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 (7628) - mean (120ms)  : 112, 128
    master - mean (119ms)  : 109, 129

    section Bailout
    This PR (7628) - mean (123ms)  : 113, 133
    master - mean (122ms)  : 113, 131

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (772ms)  : 725, 820
    master - mean (773ms)  : 727, 820

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7628) - mean (109ms)  : 99, 119
    master - mean (109ms)  : 98, 119

    section Bailout
    This PR (7628) - mean (110ms)  : 103, 117
    master - mean (109ms)  : 100, 118

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (721ms)  : 672, 769
    master - mean (727ms)  : 686, 769

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7628) - mean (106ms)  : 96, 117
    master - mean (106ms)  : 99, 114

    section Bailout
    This PR (7628) - mean (107ms)  : 98, 116
    master - mean (108ms)  : 98, 118

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (691ms)  : 654, 727
    master - mean (702ms)  : 666, 739

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 (7628) - mean (200ms)  : 193, 208
    master - mean (195ms)  : 191, 199

    section Bailout
    This PR (7628) - mean (201ms)  : 196, 206
    master - mean (200ms)  : 196, 204

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (1,125ms)  : 1060, 1189
    master - mean (1,127ms)  : 1056, 1197

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 (7628) - mean (282ms)  : 276, 289
    master - mean (279ms)  : 273, 286

    section Bailout
    This PR (7628) - mean (286ms)  : 278, 293
    master - mean (282ms)  : 272, 292

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (925ms)  : 884, 966
    master - mean (922ms)  : 875, 968

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7628) - mean (278ms)  : 266, 290
    master - mean (272ms)  : 266, 278

    section Bailout
    This PR (7628) - mean (277ms)  : 270, 284
    master - mean (272ms)  : 269, 274

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (905ms)  : 851, 960
    master - mean (902ms)  : 854, 950

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7628) - mean (272ms)  : 267, 278
    master - mean (272ms)  : 265, 278

    section Bailout
    This PR (7628) - mean (275ms)  : 268, 282
    master - mean (273ms)  : 267, 279

    section CallTarget+Inlining+NGEN
    This PR (7628) - mean (832ms)  : 808, 856
    master - mean (831ms)  : 806, 856

Loading

@lucaspimentel lucaspimentel force-pushed the lpimentel/APMSVLS-58-azfunc-host-parenting branch 2 times, most recently from 12a23e2 to 0c87ab6 Compare October 8, 2025 15:35
@pr-commenter
Copy link

pr-commenter bot commented Oct 8, 2025

Benchmarks

Benchmarks Report for benchmark platform 🐌

Benchmarks for #7628 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.197
  • 1 benchmarks are slower, with geometric mean 1.993
  • 1 benchmarks have fewer allocations
  • 6 benchmarks have more allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7628

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net472 6.09 KB 6.12 KB 33 B 0.54%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 10.6μs 59.8ns 410ns 0 0 0 5.49 KB
master StartStopWithChild netcoreapp3.1 13.7μs 72.7ns 364ns 0 0 0 5.7 KB
master StartStopWithChild net472 22.2μs 124ns 830ns 0.874 0.219 0 6.09 KB
#7628 StartStopWithChild net6.0 10.8μs 56.6ns 283ns 0 0 0 5.51 KB
#7628 StartStopWithChild netcoreapp3.1 14.1μs 53.2ns 206ns 0 0 0 5.7 KB
#7628 StartStopWithChild net472 22.2μs 121ns 674ns 0.876 0.219 0 6.12 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #7628

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 2.71 KB 2.7 KB -15 B -0.55%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 939μs 367ns 1.42μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 1.03ms 552ns 2.06μs 0 0 0 2.71 KB
master WriteAndFlushEnrichedTraces net472 1.2ms 125ns 484ns 0 0 0 3.31 KB
#7628 WriteAndFlushEnrichedTraces net6.0 934μs 263ns 1.02μs 0 0 0 2.71 KB
#7628 WriteAndFlushEnrichedTraces netcoreapp3.1 1.02ms 50.4ns 195ns 0 0 0 2.7 KB
#7628 WriteAndFlushEnrichedTraces net472 1.19ms 103ns 397ns 0 0 0 3.31 KB
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 1.12μs 0.877ns 3.4ns 0 0 0 1.22 KB
master AllCycleSimpleBody netcoreapp3.1 1.42μs 7.76ns 43.9ns 0 0 0 1.2 KB
master AllCycleSimpleBody net472 1.02μs 2.6ns 10.1ns 0.192 0 0 1.23 KB
master AllCycleMoreComplexBody net6.0 7.24μs 32.3ns 125ns 0 0 0 4.72 KB
master AllCycleMoreComplexBody netcoreapp3.1 9.06μs 43.5ns 179ns 0 0 0 4.62 KB
master AllCycleMoreComplexBody net472 7.57μs 4.62ns 17.9ns 0.721 0 0 4.74 KB
master ObjectExtractorSimpleBody net6.0 326ns 1.75ns 9.43ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 418ns 2.38ns 15.9ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 298ns 0.0238ns 0.0857ns 0.0439 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.34μs 29.8ns 115ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.91μs 36.3ns 141ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.7μs 9.57ns 37.1ns 0.6 0 0 3.8 KB
#7628 AllCycleSimpleBody net6.0 1.09μs 6.03ns 38.6ns 0 0 0 1.22 KB
#7628 AllCycleSimpleBody netcoreapp3.1 1.41μs 7.46ns 38.1ns 0 0 0 1.2 KB
#7628 AllCycleSimpleBody net472 1.01μs 0.333ns 1.25ns 0.191 0 0 1.23 KB
#7628 AllCycleMoreComplexBody net6.0 7.16μs 35.4ns 158ns 0 0 0 4.72 KB
#7628 AllCycleMoreComplexBody netcoreapp3.1 9.27μs 28ns 105ns 0 0 0 4.62 KB
#7628 AllCycleMoreComplexBody net472 7.59μs 2.68ns 10.4ns 0.724 0 0 4.74 KB
#7628 ObjectExtractorSimpleBody net6.0 316ns 1.58ns 7.24ns 0 0 0 280 B
#7628 ObjectExtractorSimpleBody netcoreapp3.1 392ns 2.23ns 14.9ns 0 0 0 272 B
#7628 ObjectExtractorSimpleBody net472 303ns 0.0428ns 0.16ns 0.044 0 0 281 B
#7628 ObjectExtractorMoreComplexBody net6.0 6.32μs 30.1ns 124ns 0 0 0 3.78 KB
#7628 ObjectExtractorMoreComplexBody netcoreapp3.1 7.74μs 38.9ns 165ns 0 0 0 3.69 KB
#7628 ObjectExtractorMoreComplexBody net472 6.7μs 2.77ns 10.7ns 0.601 0 0 3.8 KB
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EncodeArgs net6.0 76.9μs 24ns 89.7ns 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 96.2μs 276ns 1.07μs 0 0 0 32.4 KB
master EncodeArgs net472 118μs 17.2ns 66.5ns 4.69 0 0 32.5 KB
master EncodeLegacyArgs net6.0 147μs 38.7ns 145ns 0 0 0 2.15 KB
master EncodeLegacyArgs netcoreapp3.1 199μs 348ns 1.35μs 0 0 0 2.14 KB
master EncodeLegacyArgs net472 267μs 28ns 108ns 0 0 0 2.16 KB
#7628 EncodeArgs net6.0 76.3μs 23.2ns 83.8ns 0 0 0 32.4 KB
#7628 EncodeArgs netcoreapp3.1 97.6μs 207ns 773ns 0 0 0 32.4 KB
#7628 EncodeArgs net472 118μs 69.7ns 251ns 4.74 0 0 32.51 KB
#7628 EncodeLegacyArgs net6.0 146μs 59.5ns 230ns 0 0 0 2.15 KB
#7628 EncodeLegacyArgs netcoreapp3.1 198μs 156ns 604ns 0 0 0 2.14 KB
#7628 EncodeLegacyArgs net472 264μs 33.2ns 115ns 0 0 0 2.16 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #7628

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑netcoreapp3.1 1.993 298,208.84 594,258.85 bimodal

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 397μs 76ns 274ns 0 0 0 4.55 KB
master RunWafRealisticBenchmark netcoreapp3.1 411μs 285ns 1.07μs 0 0 0 4.48 KB
master RunWafRealisticBenchmark net472 427μs 63.3ns 245ns 0 0 0 4.66 KB
master RunWafRealisticBenchmarkWithAttack net6.0 284μs 41.3ns 160ns 0 0 0 2.24 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 298μs 62.7ns 226ns 0 0 0 2.22 KB
master RunWafRealisticBenchmarkWithAttack net472 311μs 21.9ns 85ns 0 0 0 2.29 KB
#7628 RunWafRealisticBenchmark net6.0 395μs 74.9ns 280ns 0 0 0 4.55 KB
#7628 RunWafRealisticBenchmark netcoreapp3.1 411μs 72ns 249ns 0 0 0 4.48 KB
#7628 RunWafRealisticBenchmark net472 433μs 40.7ns 158ns 0 0 0 4.68 KB
#7628 RunWafRealisticBenchmarkWithAttack net6.0 286μs 50.7ns 190ns 0 0 0 2.24 KB
#7628 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 614μs 11.6μs 116μs 0 0 0 2.22 KB
#7628 RunWafRealisticBenchmarkWithAttack net472 310μs 17.9ns 64.6ns 0 0 0 2.29 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 61μs 72.2ns 279ns 0 0 0 14.52 KB
master SendRequest netcoreapp3.1 70.8μs 66ns 247ns 0 0 0 17.42 KB
master SendRequest net472 0.00512ns 0.00217ns 0.00841ns 0 0 0 0 b
#7628 SendRequest net6.0 61.1μs 50.4ns 189ns 0 0 0 14.52 KB
#7628 SendRequest netcoreapp3.1 71.6μs 147ns 548ns 0 0 0 17.42 KB
#7628 SendRequest net472 0.00526ns 0.00196ns 0.00759ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master OriginalCharSlice net6.0 1.96ms 5.54μs 21.4μs 0 0 0 640.01 KB
master OriginalCharSlice netcoreapp3.1 2.08ms 2.29μs 8.25μs 0 0 0 640 KB
master OriginalCharSlice net472 2.72ms 130ns 504ns 100 0 0 641.95 KB
master OptimizedCharSlice net6.0 1.35ms 290ns 1.05μs 0 0 0 7 B
master OptimizedCharSlice netcoreapp3.1 1.66ms 498ns 1.93μs 0 0 0 1 B
master OptimizedCharSlice net472 1.99ms 418ns 1.62μs 0 0 0 73 B
master OptimizedCharSliceWithPool net6.0 849μs 60.4ns 218ns 0 0 0 4 B
master OptimizedCharSliceWithPool netcoreapp3.1 809μs 37.6ns 136ns 0 0 0 0 b
master OptimizedCharSliceWithPool net472 1.15ms 124ns 482ns 0 0 0 47 B
#7628 OriginalCharSlice net6.0 1.93ms 273ns 1.06μs 0 0 0 640.01 KB
#7628 OriginalCharSlice netcoreapp3.1 2.16ms 4.14μs 14.9μs 0 0 0 640 KB
#7628 OriginalCharSlice net472 2.68ms 80.8ns 291ns 100 0 0 641.95 KB
#7628 OptimizedCharSlice net6.0 1.39ms 146ns 564ns 0 0 0 7 B
#7628 OptimizedCharSlice netcoreapp3.1 1.67ms 656ns 2.54μs 0 0 0 1 B
#7628 OptimizedCharSlice net472 1.95ms 381ns 1.47μs 0 0 0 73 B
#7628 OptimizedCharSliceWithPool net6.0 800μs 58.8ns 212ns 0 0 0 4 B
#7628 OptimizedCharSliceWithPool netcoreapp3.1 859μs 111ns 428ns 0 0 0 0 b
#7628 OptimizedCharSliceWithPool net472 1.15ms 91.1ns 353ns 0 0 0 47 B
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Faster 🎉 More allocations ⚠️

Faster 🎉 in #7628

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 1.197 720,929.61 602,355.80

More allocations ⚠️ in #7628

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 56.5 KB 56.87 KB 363 B 0.64%
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 41.54 KB 41.81 KB 263 B 0.63%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 716μs 3.07μs 11.9μs 0 0 0 41.54 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 755μs 4.85μs 46.5μs 0 0 0 42.07 KB
master WriteAndFlushEnrichedTraces net472 866μs 3.74μs 14μs 8.93 0 0 56.5 KB
#7628 WriteAndFlushEnrichedTraces net6.0 602μs 1.28μs 4.96μs 0 0 0 41.81 KB
#7628 WriteAndFlushEnrichedTraces netcoreapp3.1 743μs 2.02μs 7.57μs 0 0 0 42.02 KB
#7628 WriteAndFlushEnrichedTraces net472 888μs 4.09μs 15.8μs 8.33 0 0 56.87 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.89μs 1.66ns 6.43ns 0 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 2.62μs 8.01ns 31ns 0 0 0 1.02 KB
master ExecuteNonQuery net472 3.03μs 3.89ns 15.1ns 0.152 0.0152 0 987 B
#7628 ExecuteNonQuery net6.0 1.92μs 4.98ns 19.3ns 0 0 0 1.02 KB
#7628 ExecuteNonQuery netcoreapp3.1 2.62μs 8.81ns 33ns 0 0 0 1.02 KB
#7628 ExecuteNonQuery net472 3.14μs 4.11ns 15.9ns 0.156 0.0156 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.72μs 0.731ns 2.83ns 0 0 0 1.03 KB
master CallElasticsearch netcoreapp3.1 2.29μs 7.79ns 30.2ns 0 0 0 1.03 KB
master CallElasticsearch net472 3.59μs 6.94ns 26.9ns 0.16 0 0 1.04 KB
master CallElasticsearchAsync net6.0 1.82μs 5.68ns 22ns 0 0 0 1.01 KB
master CallElasticsearchAsync netcoreapp3.1 2.44μs 11.9ns 51.9ns 0 0 0 1.08 KB
master CallElasticsearchAsync net472 3.79μs 4.34ns 16.8ns 0.17 0 0 1.1 KB
#7628 CallElasticsearch net6.0 1.82μs 8.05ns 31.2ns 0 0 0 1.03 KB
#7628 CallElasticsearch netcoreapp3.1 2.33μs 11.1ns 44.2ns 0 0 0 1.03 KB
#7628 CallElasticsearch net472 3.58μs 3.18ns 12.3ns 0.16 0 0 1.04 KB
#7628 CallElasticsearchAsync net6.0 1.75μs 7.43ns 27.8ns 0 0 0 1.01 KB
#7628 CallElasticsearchAsync netcoreapp3.1 2.38μs 9.36ns 36.3ns 0 0 0 1.08 KB
#7628 CallElasticsearchAsync net472 3.82μs 3.55ns 13.7ns 0.172 0 0 1.1 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.85μs 8.98ns 35.9ns 0 0 0 952 B
master ExecuteAsync netcoreapp3.1 2.44μs 1.79ns 6.68ns 0 0 0 952 B
master ExecuteAsync net472 2.58μs 4.33ns 16.8ns 0.141 0 0 915 B
#7628 ExecuteAsync net6.0 1.85μs 9.38ns 41.9ns 0 0 0 952 B
#7628 ExecuteAsync netcoreapp3.1 2.46μs 4.27ns 16.6ns 0 0 0 952 B
#7628 ExecuteAsync net472 2.57μs 0.688ns 2.67ns 0.142 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 6.77μs 4.53ns 16.9ns 0 0 0 2.36 KB
master SendAsync netcoreapp3.1 8.65μs 27.9ns 108ns 0 0 0 2.9 KB
master SendAsync net472 12.6μs 5.72ns 20.6ns 0.505 0 0 3.18 KB
#7628 SendAsync net6.0 7μs 21ns 81.3ns 0 0 0 2.36 KB
#7628 SendAsync netcoreapp3.1 8.49μs 8.48ns 31.7ns 0 0 0 2.9 KB
#7628 SendAsync net472 12.3μs 8.04ns 30.1ns 0.488 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7628

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 274.06 KB 294.91 KB 20.85 KB 7.61%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 257.18 KB 264.24 KB 7.06 KB 2.75%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 276.89 KB 278.37 KB 1.48 KB 0.53%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 46.5μs 276ns 2.66μs 0 0 0 43.97 KB
master StringConcatBenchmark netcoreapp3.1 49.8μs 257ns 1.63μs 0 0 0 43.22 KB
master StringConcatBenchmark net472 57.8μs 286ns 1.18μs 0 0 0 57.34 KB
master StringConcatAspectBenchmark net6.0 469μs 1.99μs 7.18μs 0 0 0 276.89 KB
master StringConcatAspectBenchmark netcoreapp3.1 524μs 2.19μs 7.91μs 0 0 0 257.18 KB
master StringConcatAspectBenchmark net472 410μs 1.88μs 9.78μs 0 0 0 274.06 KB
#7628 StringConcatBenchmark net6.0 45.5μs 249ns 1.99μs 0 0 0 43.76 KB
#7628 StringConcatBenchmark netcoreapp3.1 51.1μs 306ns 2.95μs 0 0 0 43.18 KB
#7628 StringConcatBenchmark net472 56.6μs 286ns 1.21μs 0 0 0 57.34 KB
#7628 StringConcatAspectBenchmark net6.0 489μs 1.87μs 6.74μs 0 0 0 278.37 KB
#7628 StringConcatAspectBenchmark netcoreapp3.1 540μs 1.94μs 7.01μs 0 0 0 264.24 KB
#7628 StringConcatAspectBenchmark net472 411μs 2.1μs 10.3μs 0 0 0 294.91 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.7μs 14.6ns 83.7ns 0 0 0 1.7 KB
master EnrichedLog netcoreapp3.1 3.63μs 12.2ns 47.3ns 0 0 0 1.7 KB
master EnrichedLog net472 4.01μs 2.3ns 8.91ns 0.26 0 0 1.64 KB
#7628 EnrichedLog net6.0 2.64μs 13.5ns 64.8ns 0 0 0 1.7 KB
#7628 EnrichedLog netcoreapp3.1 3.68μs 13.7ns 53.1ns 0 0 0 1.7 KB
#7628 EnrichedLog net472 3.86μs 2.67ns 10.3ns 0.25 0 0 1.64 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 122μs 49.2ns 190ns 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 128μs 209ns 809ns 0 0 0 4.31 KB
master EnrichedLog net472 169μs 75.6ns 293ns 0 0 0 4.52 KB
#7628 EnrichedLog net6.0 123μs 39ns 146ns 0 0 0 4.31 KB
#7628 EnrichedLog netcoreapp3.1 127μs 68.6ns 247ns 0 0 0 4.31 KB
#7628 EnrichedLog net472 167μs 51ns 184ns 0 0 0 4.52 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 4.88μs 20.8ns 80.8ns 0 0 0 2.26 KB
master EnrichedLog netcoreapp3.1 6.8μs 17.1ns 66.3ns 0 0 0 2.26 KB
master EnrichedLog net472 7.49μs 4.38ns 17ns 0.3 0 0 2.08 KB
#7628 EnrichedLog net6.0 4.96μs 24.2ns 99.6ns 0 0 0 2.26 KB
#7628 EnrichedLog netcoreapp3.1 6.82μs 19.3ns 72.1ns 0 0 0 2.26 KB
#7628 EnrichedLog net472 7.58μs 4.74ns 17.1ns 0.304 0 0 2.08 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.94μs 10.2ns 50ns 0 0 0 1.2 KB
master SendReceive netcoreapp3.1 2.56μs 12.5ns 48.4ns 0 0 0 1.2 KB
master SendReceive net472 3.01μs 3.07ns 11.5ns 0.183 0 0 1.2 KB
#7628 SendReceive net6.0 1.92μs 9.18ns 36.7ns 0 0 0 1.2 KB
#7628 SendReceive netcoreapp3.1 2.65μs 13.9ns 69.6ns 0 0 0 1.2 KB
#7628 SendReceive net472 3.02μs 4.12ns 16ns 0.181 0 0 1.2 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 4.34μs 6.48ns 25.1ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.54μs 17.2ns 66.8ns 0 0 0 1.63 KB
master EnrichedLog net472 6.83μs 7.27ns 28.2ns 0.307 0 0 2.03 KB
#7628 EnrichedLog net6.0 4.46μs 19.9ns 74.4ns 0 0 0 1.58 KB
#7628 EnrichedLog netcoreapp3.1 5.57μs 18.2ns 70.7ns 0 0 0 1.63 KB
#7628 EnrichedLog net472 6.72μs 8.59ns 33.3ns 0.303 0 0 2.03 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 769ns 4.17ns 25ns 0 0 0 576 B
master StartFinishSpan netcoreapp3.1 961ns 5.1ns 25.5ns 0 0 0 576 B
master StartFinishSpan net472 974ns 0.344ns 1.33ns 0.0883 0 0 578 B
master StartFinishScope net6.0 902ns 4.53ns 20.7ns 0 0 0 696 B
master StartFinishScope netcoreapp3.1 1.17μs 5.91ns 27.7ns 0 0 0 696 B
master StartFinishScope net472 1.18μs 0.388ns 1.5ns 0.0996 0 0 658 B
#7628 StartFinishSpan net6.0 768ns 3.11ns 11.6ns 0 0 0 576 B
#7628 StartFinishSpan netcoreapp3.1 972ns 4.25ns 16.4ns 0 0 0 576 B
#7628 StartFinishSpan net472 983ns 0.154ns 0.596ns 0.087 0 0 578 B
#7628 StartFinishScope net6.0 924ns 4.87ns 24.4ns 0 0 0 696 B
#7628 StartFinishScope netcoreapp3.1 1.22μs 5.86ns 25.5ns 0 0 0 696 B
#7628 StartFinishScope net472 1.17μs 0.87ns 3.37ns 0.0995 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 1.07μs 5.21ns 22.1ns 0 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1.5μs 7.08ns 30ns 0 0 0 696 B
master RunOnMethodBegin net472 1.43μs 0.251ns 0.938ns 0.1 0 0 658 B
#7628 RunOnMethodBegin net6.0 1.11μs 0.644ns 2.5ns 0 0 0 696 B
#7628 RunOnMethodBegin netcoreapp3.1 1.42μs 6.99ns 31.3ns 0 0 0 696 B
#7628 RunOnMethodBegin net472 1.48μs 0.707ns 2.74ns 0.103 0 0 658 B

@lucaspimentel lucaspimentel force-pushed the lpimentel/APMSVLS-58-azfunc-host-parenting branch 6 times, most recently from 9dd669c to 27ba999 Compare October 10, 2025 21:55
@lucaspimentel lucaspimentel changed the title [Azure Functions] Fix span parenting for isolated functions with ASP.NET Core integration [WIP] [Azure Functions] Fix span parenting for isolated functions with ASP.NET Core integration Oct 10, 2025
@lucaspimentel lucaspimentel force-pushed the lpimentel/APMSVLS-58-azfunc-host-parenting branch from 27ba999 to 584134a Compare October 14, 2025 20:15
@lucaspimentel lucaspimentel force-pushed the lpimentel/APMSVLS-58-azfunc-host-parenting branch 8 times, most recently from 24a8537 to aae2cfb Compare November 5, 2025 22:25
@lucaspimentel lucaspimentel force-pushed the lpimentel/APMSVLS-58-azfunc-host-parenting branch 7 times, most recently from 974a81e to 613d6bb Compare November 11, 2025 23:52
lucaspimentel and others added 29 commits November 25, 2025 11:29
Add aas.function.process tag to identify whether spans originate from the host or worker process in Azure Functions isolated mode. This helps differentiate between the two processes that exist in the isolated worker model.

Changes:
- Add AzureFunctionsProcess tag constant with possible values: host, worker
- Add IsAzureFunctionsIsolated() helper method to detect isolated functions
- Update SpanMessagePackFormatter to include the tag for isolated functions
- Tag is only added for isolated Azure Functions (not in-process functions)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Merge APMSVLS-58-solution.md into main investigation doc
- Organize traces into phase directories (1-original, 2-after-observer)
- Document trace evolution before/after enabling AspNetCoreDiagnosticObserver
- Clarify current issues: wrong parent and unnecessary host spans
- Remove obsolete baseline trace files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add captured trace files from before enabling AspNetCoreDiagnosticObserver
in worker process, showing baseline behavior where:
- No aspnet_core.request span exists in worker
- Worker's azure_functions.invoke parented to host's root span
- Host creates unnecessary azure_functions.invoke and http.request spans

Update investigation doc with detailed trace analysis and clarify goal:
make worker's azure_functions.invoke a child of aspnet_core.request span.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Replace "Next Steps" with concrete implementation plan using
HttpContext.Items as bridge between ASP.NET Core and Azure Functions
middleware. Includes specific file locations and fallback approaches.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
AsyncLocal context doesn't flow through Azure Functions middleware,
causing worker's azure_functions.invoke span to be incorrectly
parented. Use HttpContext.Items as an explicit bridge to pass the
AspNetCore scope to the Azure Functions middleware.

Changes:
- Store AspNetCore scope in HttpContext.Items after creation
- Add Items property to IFunctionContext duck type interface
- Retrieve scope from HttpContext.Items when creating azure_functions.invoke span
- Only use HttpContext.Items fallback when tracer.InternalActiveScope is null

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@lucaspimentel lucaspimentel force-pushed the lpimentel/APMSVLS-58-azfunc-host-parenting branch from f0336b8 to 01f415c Compare November 25, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants