Skip to content

Comments

[tracing] Create and reparent span for Azure API Management#7806

Open
jcstorms1 wants to merge 58 commits intomasterfrom
storms/add-azure-apim-proxy
Open

[tracing] Create and reparent span for Azure API Management#7806
jcstorms1 wants to merge 58 commits intomasterfrom
storms/add-azure-apim-proxy

Conversation

@jcstorms1
Copy link

@jcstorms1 jcstorms1 commented Nov 12, 2025

Summary of changes

  • New logic to identify Azure API Management headers
  • Correctly creates an APIM span and reparents it as the parent for Isolated HTTP Azure Functions
  • Refactored existing AWS proxy logic and tests to account for the addition of the Azure Proxy.
  • Changes inferred proxy span.kind to server instead of internal to follow this spec

Note: This PR does not include functions using ASP.NET Core and will be added later

image

Reason for change

This is a frequently requested feature for proper distributed tracing with Azure Functions using APIM

APMSVLS-245

Implementation details

Test coverage

Other details

@pr-commenter
Copy link

pr-commenter bot commented Nov 12, 2025

Benchmarks

Benchmark execution time: 2026-02-23 20:59:14

Comparing candidate commit c17569d in PR branch storms/add-azure-apim-proxy with baseline commit caa8d05 in branch master.

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

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

  • 🟩 execution_time [-22.186ms; -17.586ms] or [-10.068%; -7.981%]

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

  • 🟥 execution_time [+15.296ms; +21.468ms] or [+7.747%; +10.873%]

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

  • 🟩 execution_time [-20.320ms; -19.640ms] or [-10.030%; -9.694%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟩 execution_time [-19.446ms; -11.462ms] or [-12.499%; -7.367%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0

  • 🟩 execution_time [-74.630µs; -68.423µs] or [-6.602%; -6.053%]
  • 🟩 throughput [+57.113op/s; +62.437op/s] or [+6.456%; +7.058%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • 🟩 execution_time [-10.286µs; -5.653µs] or [-20.565%; -11.302%]
  • 🟩 throughput [+2615.642op/s; +4340.716op/s] or [+12.825%; +21.283%]

scenario:Benchmarks.Trace.NLogBenchmark.EnrichedLog netcoreapp3.1

  • 🟩 throughput [+9769.570op/s; +12816.192op/s] or [+6.998%; +9.180%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+31.294ms; +34.771ms] or [+32.206%; +35.785%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟩 throughput [+15104177.904op/s; +16274957.926op/s] or [+6.709%; +7.229%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟩 execution_time [-20.278ms; -14.896ms] or [-9.375%; -6.887%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟥 execution_time [+16.812ms; +22.512ms] or [+8.474%; +11.347%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

  • 🟩 execution_time [-15.402ms; -10.472ms] or [-7.399%; -5.031%]

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

dd-trace-dotnet-ci-bot bot commented Nov 12, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (7806) 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
duration73.60 ± (73.63 - 73.95) ms76.78 ± (76.77 - 77.16) ms+4.3%✅⬆️
.NET Framework 4.8 - Bailout
duration77.86 ± (77.86 - 78.19) ms81.61 ± (81.28 - 81.69) ms+4.8%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1067.52 ± (1068.28 - 1074.61) ms1095.82 ± (1094.69 - 1100.54) ms+2.7%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms22.41 ± (22.37 - 22.45) ms23.28 ± (23.23 - 23.33) ms+3.9%✅⬆️
process.time_to_main_ms84.61 ± (84.42 - 84.79) ms89.09 ± (88.90 - 89.28) ms+5.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.92 ± (10.91 - 10.92) MB10.91 ± (10.90 - 10.91) MB-0.1%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.38 ± (22.34 - 22.42) ms23.01 ± (22.97 - 23.06) ms+2.8%✅⬆️
process.time_to_main_ms86.01 ± (85.83 - 86.19) ms90.14 ± (89.95 - 90.34) ms+4.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.96 ± (10.95 - 10.96) MB10.96 ± (10.95 - 10.96) MB+0.0%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms240.44 ± (236.44 - 244.45) ms240.07 ± (235.97 - 244.16) ms-0.2%
process.time_to_main_ms485.58 ± (485.00 - 486.15) ms501.36 ± (500.55 - 502.16) ms+3.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed47.64 ± (47.62 - 47.66) MB47.67 ± (47.64 - 47.69) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.0%
.NET 6 - Baseline
process.internal_duration_ms21.33 ± (21.28 - 21.38) ms22.06 ± (22.01 - 22.11) ms+3.4%✅⬆️
process.time_to_main_ms73.84 ± (73.69 - 73.99) ms77.91 ± (77.74 - 78.08) ms+5.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.63 ± (10.63 - 10.64) MB10.64 ± (10.64 - 10.64) MB+0.0%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.25 ± (21.20 - 21.31) ms21.99 ± (21.93 - 22.05) ms+3.5%✅⬆️
process.time_to_main_ms75.06 ± (74.90 - 75.23) ms79.48 ± (79.26 - 79.69) ms+5.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.69 ± (10.68 - 10.69) MB10.75 ± (10.74 - 10.75) MB+0.6%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms255.98 ± (253.38 - 258.59) ms252.80 ± (248.66 - 256.94) ms-1.2%
process.time_to_main_ms466.93 ± (466.39 - 467.47) ms485.45 ± (484.71 - 486.19) ms+4.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.41 ± (48.39 - 48.44) MB48.26 ± (48.24 - 48.28) MB-0.3%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.2%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms19.58 ± (19.55 - 19.61) ms20.32 ± (20.27 - 20.36) ms+3.8%✅⬆️
process.time_to_main_ms73.54 ± (73.38 - 73.71) ms77.58 ± (77.41 - 77.75) ms+5.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.66 ± (7.66 - 7.67) MB7.66 ± (7.66 - 7.66) MB-0.0%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.65 ± (19.61 - 19.70) ms20.35 ± (20.29 - 20.40) ms+3.5%✅⬆️
process.time_to_main_ms74.82 ± (74.66 - 74.97) ms78.62 ± (78.45 - 78.78) ms+5.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.71 ± (7.71 - 7.72) MB7.73 ± (7.72 - 7.73) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms189.13 ± (188.38 - 189.88) ms192.88 ± (191.96 - 193.80) ms+2.0%✅⬆️
process.time_to_main_ms451.15 ± (450.51 - 451.78) ms466.12 ± (465.35 - 466.89) ms+3.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.01 ± (35.97 - 36.04) MB36.17 ± (36.10 - 36.23) MB+0.4%✅⬆️
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
duration191.74 ± (191.76 - 192.80) ms201.11 ± (200.60 - 201.58) ms+4.9%✅⬆️
.NET Framework 4.8 - Bailout
duration194.61 ± (194.58 - 195.07) ms200.98 ± (200.83 - 201.92) ms+3.3%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1133.00 ± (1135.30 - 1142.49) ms1168.60 ± (1167.40 - 1176.20) ms+3.1%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms186.45 ± (186.12 - 186.77) ms194.64 ± (194.11 - 195.17) ms+4.4%✅⬆️
process.time_to_main_ms80.48 ± (80.27 - 80.70) ms84.19 ± (83.90 - 84.47) ms+4.6%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.21 ± (16.17 - 16.24) MB15.97 ± (15.95 - 15.99) MB-1.5%
runtime.dotnet.threads.count19 ± (19 - 20)20 ± (20 - 20)+0.3%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms185.31 ± (184.98 - 185.63) ms193.03 ± (192.55 - 193.51) ms+4.2%✅⬆️
process.time_to_main_ms81.90 ± (81.73 - 82.07) ms85.02 ± (84.80 - 85.24) ms+3.8%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.28 ± (16.25 - 16.31) MB16.05 ± (16.03 - 16.07) MB-1.4%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)-0.4%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms434.52 ± (432.09 - 436.95) ms430.68 ± (427.10 - 434.27) ms-0.9%
process.time_to_main_ms470.33 ± (469.83 - 470.83) ms490.75 ± (489.42 - 492.07) ms+4.3%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed57.94 ± (57.82 - 58.06) MB58.07 ± (57.97 - 58.18) MB+0.2%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 30)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms190.39 ± (190.06 - 190.72) ms198.19 ± (197.68 - 198.71) ms+4.1%✅⬆️
process.time_to_main_ms69.89 ± (69.69 - 70.08) ms72.39 ± (72.16 - 72.62) ms+3.6%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.15 ± (16.02 - 16.29) MB16.36 ± (16.34 - 16.38) MB+1.3%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)19 ± (19 - 19)+6.1%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms188.91 ± (188.65 - 189.17) ms196.15 ± (195.68 - 196.62) ms+3.8%✅⬆️
process.time_to_main_ms70.64 ± (70.54 - 70.75) ms72.95 ± (72.76 - 73.14) ms+3.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed15.82 ± (15.65 - 15.99) MB16.33 ± (16.31 - 16.35) MB+3.2%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)20 ± (20 - 20)+7.1%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms448.62 ± (446.97 - 450.28) ms456.59 ± (454.46 - 458.72) ms+1.8%✅⬆️
process.time_to_main_ms446.89 ± (446.38 - 447.41) ms458.95 ± (457.93 - 459.97) ms+2.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.15 ± (58.04 - 58.26) MB57.90 ± (57.79 - 58.01) MB-0.4%
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms187.68 ± (187.40 - 187.96) ms193.90 ± (193.47 - 194.32) ms+3.3%✅⬆️
process.time_to_main_ms69.19 ± (69.02 - 69.37) ms71.01 ± (70.81 - 71.22) ms+2.6%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.76 ± (11.73 - 11.79) MB11.72 ± (11.71 - 11.74) MB-0.3%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.8%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms187.45 ± (187.15 - 187.76) ms190.94 ± (190.49 - 191.39) ms+1.9%✅⬆️
process.time_to_main_ms70.34 ± (70.20 - 70.48) ms71.61 ± (71.39 - 71.84) ms+1.8%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.77 ± (11.69 - 11.85) MB11.76 ± (11.74 - 11.78) MB-0.1%
runtime.dotnet.threads.count19 ± (18 - 19)19 ± (19 - 19)+3.8%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms363.28 ± (361.91 - 364.66) ms371.68 ± (370.42 - 372.94) ms+2.3%✅⬆️
process.time_to_main_ms429.75 ± (429.20 - 430.29) ms442.41 ± (441.40 - 443.42) ms+2.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.73 ± (47.68 - 47.78) MB47.75 ± (47.72 - 47.79) MB+0.1%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.1%✅⬆️
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 (7806) - mean (77ms)  : 74, 80
    master - mean (74ms)  : 72, 76

    section Bailout
    This PR (7806) - mean (81ms)  : 79, 84
    master - mean (78ms)  : 76, 80

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (1,098ms)  : 1056, 1140
    master - mean (1,071ms)  : 1026, 1117

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 (7806) - mean (120ms)  : 116, 123
    master - mean (114ms)  : 111, 117

    section Bailout
    This PR (7806) - mean (120ms)  : 118, 123
    master - mean (115ms)  : 113, 117

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (779ms)  : 705, 852
    master - mean (757ms)  : 693, 822

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7806) - mean (107ms)  : 104, 110
    master - mean (102ms)  : 98, 105

    section Bailout
    This PR (7806) - mean (108ms)  : 105, 111
    master - mean (103ms)  : 101, 105

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (770ms)  : 693, 846
    master - mean (759ms)  : 712, 805

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7806) - mean (106ms)  : 103, 109
    master - mean (101ms)  : 98, 104

    section Bailout
    This PR (7806) - mean (107ms)  : 105, 109
    master - mean (102ms)  : 100, 105

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (689ms)  : 668, 709
    master - mean (672ms)  : 653, 692

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 (7806) - mean (201ms)  : 195, 207
    master - mean (192ms)  : 187, 198

    section Bailout
    This PR (7806) - mean (201ms)  : 195, 208
    master - mean (195ms)  : 192, 197

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (1,172ms)  : 1107, 1237
    master - mean (1,139ms)  : 1087, 1191

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 (7806) - mean (288ms)  : 276, 299
    master - mean (275ms)  : 270, 280

    section Bailout
    This PR (7806) - mean (287ms)  : 275, 298
    master - mean (275ms)  : 271, 280

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (957ms)  : 892, 1022
    master - mean (934ms)  : 890, 978

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7806) - mean (279ms)  : 267, 290
    master - mean (268ms)  : 264, 273

    section Bailout
    This PR (7806) - mean (278ms)  : 266, 289
    master - mean (268ms)  : 264, 271

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (943ms)  : 898, 988
    master - mean (926ms)  : 907, 945

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7806) - mean (275ms)  : 265, 285
    master - mean (267ms)  : 262, 271

    section Bailout
    This PR (7806) - mean (272ms)  : 266, 278
    master - mean (267ms)  : 262, 272

    section CallTarget+Inlining+NGEN
    This PR (7806) - mean (846ms)  : 819, 874
    master - mean (824ms)  : 808, 841

Loading

@datadog-official

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

10 occurrences of :

-      span.kind: internal,
+      span.kind: server,

@jcstorms1 jcstorms1 requested a review from a team as a code owner February 18, 2026 18:46
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.

3 participants