Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call HttpRequest.BuildUrl to avoid URL caching #6361

Merged
merged 8 commits into from
Feb 10, 2025
Merged

Conversation

bouwkast
Copy link
Contributor

@bouwkast bouwkast commented Nov 27, 2024

Summary of changes

Manually compute the value of HttpRequest.Url for .NET Framework so that that it won't be cached for other callers due to us.

Reason for change

For .NET Framework we access HttpRequest.Url when adding data to Spans.
When called this method will build the URL of the HttpRequest if we are the first accessors and then the result will be cached in a private field _url.

The issue here is that there seems to be a few edge cases where this causes us to build the HttpRequest before it is desired to be built.

Implementation details

Adds a new feature flag: BypassHttpRequestUrlCachingEnabled to allow bypassing of the current behavior where the URL would be cached.

Duck types the HttpRequest BuildUrl function to manually build the URL to avoid caching it when enabled.

Test coverage

Added some unit tests for this that rely on reflection and attempted to emulate previous behavior and the behavior we want to fix.

Other details

I'm not confident that this a smart idea.

We will end up with an incorrect value here, but we did previously as well (only in these rare cases) but we will hopefully get ourselves out of the picture of affecting/altering application behavior.

https://datadoghq.atlassian.net/browse/AIDM-500

@bouwkast bouwkast requested a review from a team as a code owner November 27, 2024 00:36
@andrewlock
Copy link
Member

andrewlock commented Nov 27, 2024

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

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 shown 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).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6361) - mean (69ms)  : 67, 72
     .   : milestone, 69,
    master - mean (69ms)  : 67, 72
     .   : milestone, 69,

    section CallTarget+Inlining+NGEN
    This PR (6361) - mean (984ms)  : 960, 1008
     .   : milestone, 984,
    master - mean (983ms)  : 953, 1012
     .   : milestone, 983,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6361) - mean (108ms)  : 105, 111
     .   : milestone, 108,
    master - mean (108ms)  : 106, 110
     .   : milestone, 108,

    section CallTarget+Inlining+NGEN
    This PR (6361) - mean (677ms)  : 661, 694
     .   : milestone, 677,
    master - mean (678ms)  : 662, 695
     .   : milestone, 678,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6361) - mean (91ms)  : 89, 93
     .   : milestone, 91,
    master - mean (91ms)  : 89, 94
     .   : milestone, 91,

    section CallTarget+Inlining+NGEN
    This PR (6361) - mean (633ms)  : 616, 650
     .   : milestone, 633,
    master - mean (632ms)  : 615, 648
     .   : milestone, 632,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6361) - mean (190ms)  : 186, 194
     .   : milestone, 190,
    master - mean (190ms)  : 185, 195
     .   : milestone, 190,

    section CallTarget+Inlining+NGEN
    This PR (6361) - mean (1,088ms)  : 1061, 1114
     .   : milestone, 1088,
    master - mean (1,083ms)  : 1060, 1106
     .   : milestone, 1083,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6361) - mean (278ms)  : 271, 286
     .   : milestone, 278,
    master - mean (276ms)  : 273, 280
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (6361) - mean (860ms)  : 828, 891
     .   : milestone, 860,
    master - mean (868ms)  : 834, 901
     .   : milestone, 868,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6361) - mean (264ms)  : 259, 269
     .   : milestone, 264,
    master - mean (264ms)  : 259, 268
     .   : milestone, 264,

    section CallTarget+Inlining+NGEN
    This PR (6361) - mean (846ms)  : 809, 883
     .   : milestone, 846,
    master - mean (842ms)  : 809, 875
     .   : milestone, 842,

Loading

@andrewlock
Copy link
Member

Throughput/Crank Report ⚡

Throughput results for AspNetCoreSimpleController comparing the following branches/commits:

Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red.

Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards!

gantt
    title Throughput Linux x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6361) (11.255M)   : 0, 11255395
    master (11.198M)   : 0, 11198348
    benchmarks/2.9.0 (11.033M)   : 0, 11032866

    section Automatic
    This PR (6361) (7.353M)   : 0, 7353456
    master (7.205M)   : 0, 7205466
    benchmarks/2.9.0 (7.786M)   : 0, 7785853

    section Trace stats
    master (7.443M)   : 0, 7442635

    section Manual
    master (11.218M)   : 0, 11217680

    section Manual + Automatic
    This PR (6361) (6.745M)   : 0, 6744898
    master (6.727M)   : 0, 6726536

    section DD_TRACE_ENABLED=0
    master (10.410M)   : 0, 10409702

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6361) (9.629M)   : 0, 9628527
    master (9.510M)   : 0, 9510466
    benchmarks/2.9.0 (9.495M)   : 0, 9494821

    section Automatic
    This PR (6361) (6.485M)   : 0, 6485329
    master (6.331M)   : 0, 6331398

    section Trace stats
    master (6.659M)   : 0, 6658730

    section Manual
    master (9.280M)   : 0, 9280107

    section Manual + Automatic
    This PR (6361) (6.052M)   : 0, 6051963
    master (5.691M)   : 0, 5690770

    section DD_TRACE_ENABLED=0
    master (8.840M)   : 0, 8840434

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6361) (9.764M)   : 0, 9763785
    master (10.163M)   : 0, 10163050
    benchmarks/2.9.0 (10.020M)   : 0, 10019592

    section Automatic
    This PR (6361) (6.031M)   : crit ,0, 6030603
    master (6.829M)   : 0, 6828973
    benchmarks/2.9.0 (7.255M)   : 0, 7255257

    section Trace stats
    master (7.555M)   : 0, 7554541

    section Manual
    master (10.735M)   : 0, 10735441

    section Manual + Automatic
    This PR (6361) (5.688M)   : crit ,0, 5688255
    master (6.575M)   : 0, 6575410

    section DD_TRACE_ENABLED=0
    master (10.155M)   : 0, 10155272

Loading

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Nov 27, 2024

Datadog Report

Branch report: steven/owin-fix
Commit report: 4de08bc
Test service: dd-trace-dotnet

❌ 2 Failed (0 Known Flaky), 232869 Passed, 2076 Skipped, 18h 33m 12.85s Total Time

❌ Failed Tests (2)

  • SubmitTraces - Datadog.Trace.ClrProfiler.IntegrationTests.CI.NUnitEvpTests - Details

    Expand for error
     The sample did not exit in 600000ms. Memory dump taken: True. Killing process.
    
  • TestInstrumentedUnitTests - Datadog.Trace.Security.IntegrationTests.Iast.IastInstrumentationUnitTests - Details

    Expand for error
     Expected exit code: 0, actual exit code: 1.
    

@andrewlock
Copy link
Member

andrewlock commented Nov 27, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #6361 compared to master:

  • 2 benchmarks are slower, with geometric mean 1.152
  • All benchmarks have the same 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 ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 8.23μs 45.9ns 315ns 0.0205 0.0123 0.0041 5.6 KB
master StartStopWithChild netcoreapp3.1 9.82μs 50.9ns 233ns 0.0146 0.00487 0 5.8 KB
master StartStopWithChild net472 16.1μs 58.7ns 219ns 1.04 0.306 0.0967 6.21 KB
#6361 StartStopWithChild net6.0 7.93μs 45.2ns 329ns 0.0116 0.00385 0 5.61 KB
#6361 StartStopWithChild netcoreapp3.1 9.99μs 49.5ns 210ns 0.0204 0.0051 0 5.8 KB
#6361 StartStopWithChild net472 16μs 45.3ns 175ns 1.04 0.307 0.102 6.21 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 521μs 668ns 2.5μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 650μs 343ns 1.33μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 856μs 490ns 1.9μs 0.428 0 0 3.3 KB
#6361 WriteAndFlushEnrichedTraces net6.0 495μs 1.39μs 5.38μs 0 0 0 2.7 KB
#6361 WriteAndFlushEnrichedTraces netcoreapp3.1 660μs 429ns 1.66μs 0 0 0 2.7 KB
#6361 WriteAndFlushEnrichedTraces net472 848μs 196ns 732ns 0.425 0 0 3.3 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 129μs 404ns 1.56μs 0.195 0 0 14.47 KB
master SendRequest netcoreapp3.1 140μs 564ns 2.18μs 0.207 0 0 17.27 KB
master SendRequest net472 0.0224ns 0.00436ns 0.0169ns 0 0 0 0 b
#6361 SendRequest net6.0 131μs 445ns 1.72μs 0.198 0 0 14.47 KB
#6361 SendRequest netcoreapp3.1 144μs 403ns 1.56μs 0.211 0 0 17.27 KB
#6361 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 563μs 2.68μs 11.1μs 0.566 0 0 41.41 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 660μs 2.53μs 9.45μs 0.327 0 0 41.62 KB
master WriteAndFlushEnrichedTraces net472 838μs 3.2μs 12μs 8.22 2.47 0.411 53.29 KB
#6361 WriteAndFlushEnrichedTraces net6.0 557μs 2.86μs 13.4μs 0.548 0 0 41.61 KB
#6361 WriteAndFlushEnrichedTraces netcoreapp3.1 651μs 2.27μs 10.7μs 0.332 0 0 41.59 KB
#6361 WriteAndFlushEnrichedTraces net472 820μs 2.64μs 9.9μs 8.06 2.42 0.403 53.27 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.25μs 0.848ns 3.28ns 0.0144 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.71μs 1.23ns 4.59ns 0.0137 0 0 1.02 KB
master ExecuteNonQuery net472 1.92μs 2.24ns 8.68ns 0.157 0.000961 0 987 B
#6361 ExecuteNonQuery net6.0 1.16μs 0.835ns 3.13ns 0.0146 0 0 1.02 KB
#6361 ExecuteNonQuery netcoreapp3.1 1.77μs 0.957ns 3.71ns 0.0133 0 0 1.02 KB
#6361 ExecuteNonQuery net472 1.99μs 1.4ns 5.41ns 0.156 0.001 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.29μs 0.681ns 2.55ns 0.0136 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.5μs 0.374ns 1.35ns 0.0128 0 0 976 B
master CallElasticsearch net472 2.51μs 1.28ns 4.8ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.25μs 0.539ns 2.02ns 0.0132 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.62μs 2.58ns 9.66ns 0.0137 0 0 1.02 KB
master CallElasticsearchAsync net472 2.62μs 1.68ns 6.28ns 0.167 0 0 1.05 KB
#6361 CallElasticsearch net6.0 1.27μs 0.756ns 2.73ns 0.0134 0 0 976 B
#6361 CallElasticsearch netcoreapp3.1 1.56μs 0.538ns 1.94ns 0.0133 0 0 976 B
#6361 CallElasticsearch net472 2.5μs 1.98ns 7.65ns 0.158 0 0 995 B
#6361 CallElasticsearchAsync net6.0 1.26μs 0.585ns 2.74ns 0.0134 0 0 952 B
#6361 CallElasticsearchAsync netcoreapp3.1 1.65μs 1.81ns 6.79ns 0.0133 0 0 1.02 KB
#6361 CallElasticsearchAsync net472 2.71μs 1.32ns 5.11ns 0.167 0 0 1.05 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.31μs 0.619ns 2.4ns 0.0132 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.63μs 0.778ns 3.01ns 0.0124 0 0 952 B
master ExecuteAsync net472 1.84μs 0.383ns 1.43ns 0.145 0 0 915 B
#6361 ExecuteAsync net6.0 1.31μs 0.494ns 1.85ns 0.0133 0 0 952 B
#6361 ExecuteAsync netcoreapp3.1 1.58μs 1ns 3.76ns 0.0125 0 0 952 B
#6361 ExecuteAsync net472 1.79μs 0.497ns 1.92ns 0.145 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 4.42μs 1.51ns 5.66ns 0.0309 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.38μs 1.63ns 6.1ns 0.0376 0 0 2.85 KB
master SendAsync net472 7.38μs 1.79ns 6.95ns 0.496 0 0 3.12 KB
#6361 SendAsync net6.0 4.54μs 2.13ns 8.25ns 0.0318 0 0 2.31 KB
#6361 SendAsync netcoreapp3.1 5.36μs 2.54ns 9.85ns 0.0374 0 0 2.85 KB
#6361 SendAsync net472 7.4μs 1.16ns 4.5ns 0.495 0 0 3.12 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 1.52μs 0.699ns 2.61ns 0.0228 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.26μs 1.61ns 6.24ns 0.0214 0 0 1.64 KB
master EnrichedLog net472 2.53μs 0.661ns 2.47ns 0.249 0 0 1.57 KB
#6361 EnrichedLog net6.0 1.6μs 0.978ns 3.66ns 0.0231 0 0 1.64 KB
#6361 EnrichedLog netcoreapp3.1 2.19μs 1.03ns 3.7ns 0.0218 0 0 1.64 KB
#6361 EnrichedLog net472 2.65μs 1.05ns 3.92ns 0.249 0 0 1.57 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 116μs 146ns 545ns 0.0582 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 120μs 166ns 644ns 0.0597 0 0 4.28 KB
master EnrichedLog net472 150μs 82.9ns 321ns 0.677 0.226 0 4.46 KB
#6361 EnrichedLog net6.0 117μs 95.5ns 344ns 0.0583 0 0 4.28 KB
#6361 EnrichedLog netcoreapp3.1 120μs 109ns 409ns 0 0 0 4.28 KB
#6361 EnrichedLog net472 151μs 105ns 406ns 0.676 0.225 0 4.46 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 3.16μs 1.52ns 5.48ns 0.03 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.34μs 1.67ns 6.47ns 0.0283 0 0 2.2 KB
master EnrichedLog net472 5.02μs 1.31ns 5.06ns 0.319 0 0 2.02 KB
#6361 EnrichedLog net6.0 3.12μs 0.588ns 2.28ns 0.0297 0 0 2.2 KB
#6361 EnrichedLog netcoreapp3.1 4.32μs 2.68ns 10.4ns 0.0281 0 0 2.2 KB
#6361 EnrichedLog net472 4.86μs 0.768ns 2.98ns 0.321 0 0 2.02 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.46μs 0.5ns 1.94ns 0.0161 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.89μs 0.609ns 2.28ns 0.0151 0 0 1.14 KB
master SendReceive net472 2.15μs 0.785ns 3.04ns 0.183 0 0 1.16 KB
#6361 SendReceive net6.0 1.38μs 1.73ns 6.47ns 0.0159 0 0 1.14 KB
#6361 SendReceive netcoreapp3.1 1.72μs 4.21ns 16.3ns 0.0153 0 0 1.14 KB
#6361 SendReceive net472 2.06μs 1.12ns 4.34ns 0.183 0 0 1.16 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 2.83μs 0.957ns 3.7ns 0.0213 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.94μs 3.02ns 11.7ns 0.0217 0 0 1.65 KB
master EnrichedLog net472 4.46μs 2.86ns 11.1ns 0.322 0 0 2.04 KB
#6361 EnrichedLog net6.0 2.6μs 1.08ns 4.17ns 0.0222 0 0 1.6 KB
#6361 EnrichedLog netcoreapp3.1 3.99μs 2.57ns 9.94ns 0.0216 0 0 1.65 KB
#6361 EnrichedLog net472 4.32μs 2.89ns 11.2ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6361

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 1.155 687.47 794.35
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.149 396.60 455.53

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 396ns 0.4ns 1.55ns 0.0081 0 0 576 B
master StartFinishSpan netcoreapp3.1 577ns 0.721ns 2.79ns 0.00786 0 0 576 B
master StartFinishSpan net472 645ns 1.54ns 5.97ns 0.0916 0 0 578 B
master StartFinishScope net6.0 539ns 0.536ns 2.07ns 0.00986 0 0 696 B
master StartFinishScope netcoreapp3.1 688ns 1.1ns 4.25ns 0.00943 0 0 696 B
master StartFinishScope net472 799ns 2.8ns 10.8ns 0.104 0 0 658 B
#6361 StartFinishSpan net6.0 455ns 0.662ns 2.56ns 0.00804 0 0 576 B
#6361 StartFinishSpan netcoreapp3.1 636ns 2.03ns 7.86ns 0.00771 0 0 576 B
#6361 StartFinishSpan net472 645ns 1.29ns 4.99ns 0.0918 0 0 578 B
#6361 StartFinishScope net6.0 487ns 0.468ns 1.81ns 0.00973 0 0 696 B
#6361 StartFinishScope netcoreapp3.1 795ns 0.935ns 3.62ns 0.00955 0 0 696 B
#6361 StartFinishScope net472 780ns 1.75ns 6.77ns 0.104 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 655ns 0.62ns 2.4ns 0.00988 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 939ns 1.56ns 6.05ns 0.00936 0 0 696 B
master RunOnMethodBegin net472 1.05μs 3.37ns 12.6ns 0.104 0 0 658 B
#6361 RunOnMethodBegin net6.0 599ns 1.44ns 5.57ns 0.00981 0 0 696 B
#6361 RunOnMethodBegin netcoreapp3.1 942ns 2.02ns 7.83ns 0.00933 0 0 696 B
#6361 RunOnMethodBegin net472 1.08μs 2.42ns 9.38ns 0.104 0 0 658 B

@bouwkast
Copy link
Contributor Author

Based on the benchmark results this appears to have a pretty large hit.

@kevingosse
Copy link
Collaborator

Based on the benchmark results this appears to have a pretty large hit.

I don't think any of those benchmarks test this path. That said, you might want to use ducktyping instead of reflection, it's supposed to be faster.

@bouwkast bouwkast changed the title Reset HttpRequest.Url when we access it Call HttpRequest.BuildUrl to avoid URL caching Jan 27, 2025
Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

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

Nice work, even if it yucky 😃

@@ -653,5 +653,6 @@
"crashtracking_debug_url": "crashtracking_debug_url",
"debug_stack_enabled": "debug_stack_enabled",
"DD_TRACE_BAGGAGE_MAX_ITEMS": "trace_baggage_max_items",
"DD_TRACE_BAGGAGE_MAX_BYTES": "trace_baggage_max_bytes"
"DD_TRACE_BAGGAGE_MAX_BYTES": "trace_baggage_max_bytes",
"DD_TRACE_BYPASS_HTTP_REQUEST_URL_CACHING_ENABLED": "trace_bypass_http_request_url_caching_enabled"
Copy link
Member

Choose a reason for hiding this comment

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

Don't forget to make a request to dd-go for this

@andrewlock
Copy link
Member

andrewlock commented Jan 27, 2025

Based on the benchmark results this appears to have a pretty large hit.

I don't think any of those benchmarks test this path. That said, you might want to use ducktyping instead of reflection, it's supposed to be faster.

Just to confirm, the throughput tests are only for ASP.NET Core, so definitely unrelated

By swapping to calling BuildUrl we bypass any caching
logic for the Url.
This splits them into two:

- GetUrl is the old behavior where the URL will be cached in .NET Framework
- BuildUrl is the new behavior (controlled by a feature flag) where the URL will not be cached
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jan 29, 2025

Datadog Report

Branch report: steven/owin-fix
Commit report: b2e1152
Test service: dd-trace-dotnet

✅ 0 Failed, 243669 Passed, 2094 Skipped, 18h 54m 30.23s Total Time

@bouwkast bouwkast merged commit 014828e into master Feb 10, 2025
133 of 137 checks passed
@bouwkast bouwkast deleted the steven/owin-fix branch February 10, 2025 15:32
@github-actions github-actions bot added this to the vNext-v3 milestone Feb 10, 2025
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.

4 participants