dd-trace-dotnet icon indicating copy to clipboard operation
dd-trace-dotnet copied to clipboard

Fix GRPC integration

Open tonyredondo opened this issue 1 year ago • 4 comments

Summary of changes

This PR fixes the current GRPC integration.

Reason for change

The following error has been seen in the Error tracking product: image

Implementation details

Instead of calling DuckCast directly that can throw, we use TryDuckCast to check if we can use the ducktype struct before.

tonyredondo avatar Aug 28 '24 12:08 tonyredondo

Datadog Report

Branch report: tony/remove-grpc-unsupported-versions Commit report: 183fdd4 Test service: dd-trace-dotnet

:white_check_mark: 0 Failed, 449437 Passed, 2559 Skipped, 19h 16m 50.42s Total Time

datadog-ddstaging[bot] avatar Aug 28 '24 13:08 datadog-ddstaging[bot]

Execution-Time Benchmarks Report :stopwatch:

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 (5958) - mean (72ms)  : 60, 84
     .   : milestone, 72,
    master - mean (72ms)  : 63, 81
     .   : milestone, 72,

    section CallTarget+Inlining+NGEN
    This PR (5958) - mean (1,110ms)  : 1091, 1128
     .   : milestone, 1110,
    master - mean (1,107ms)  : 1082, 1132
     .   : milestone, 1107,

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

    section CallTarget+Inlining+NGEN
    This PR (5958) - mean (763ms)  : 745, 782
     .   : milestone, 763,
    master - mean (770ms)  : 753, 786
     .   : milestone, 770,

gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5958) - mean (92ms)  : 89, 95
     .   : milestone, 92,
    master - mean (92ms)  : 90, 94
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (5958) - mean (721ms)  : 706, 735
     .   : milestone, 721,
    master - mean (725ms)  : 709, 741
     .   : milestone, 725,

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

    section CallTarget+Inlining+NGEN
    This PR (5958) - mean (1,206ms)  : 1186, 1226
     .   : milestone, 1206,
    master - mean (1,213ms)  : 1190, 1237
     .   : milestone, 1213,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5958) - mean (277ms)  : 272, 281
     .   : milestone, 277,
    master - mean (276ms)  : 271, 280
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (5958) - mean (943ms)  : 924, 962
     .   : milestone, 943,
    master - mean (945ms)  : 929, 960
     .   : milestone, 945,

gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5958) - mean (266ms)  : 260, 272
     .   : milestone, 266,
    master - mean (265ms)  : 260, 270
     .   : milestone, 265,

    section CallTarget+Inlining+NGEN
    This PR (5958) - mean (927ms)  : 907, 946
     .   : milestone, 927,
    master - mean (930ms)  : 907, 952
     .   : milestone, 930,

andrewlock avatar Aug 28 '24 13:08 andrewlock

Benchmarks Report for tracer :snail:

Benchmarks for #5958 compared to master:

  • 2 benchmarks are faster, with geometric mean 1.179
  • 1 benchmarks are slower, with geometric mean 1.146
  • 1 benchmarks have fewer 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 :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.95μs 43.2ns 245ns 0.0149 0.00746 0 5.61 KB
master StartStopWithChild netcoreapp3.1 9.93μs 56ns 367ns 0.0196 0.00981 0 5.8 KB
master StartStopWithChild net472 16.5μs 43.4ns 168ns 1.07 0.342 0.0894 6.21 KB
#5958 StartStopWithChild net6.0 8.08μs 46.8ns 377ns 0.0152 0.00762 0 5.61 KB
#5958 StartStopWithChild netcoreapp3.1 10.3μs 57.6ns 386ns 0.0153 0.00511 0 5.8 KB
#5958 StartStopWithChild net472 16.7μs 48.1ns 186ns 1.05 0.329 0.0988 6.21 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 507μs 240ns 930ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 644μs 270ns 1.01μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 858μs 288ns 1.04μs 0.428 0 0 3.3 KB
#5958 WriteAndFlushEnrichedTraces net6.0 490μs 1.1μs 4.27μs 0 0 0 2.7 KB
#5958 WriteAndFlushEnrichedTraces netcoreapp3.1 648μs 630ns 2.44μs 0 0 0 2.7 KB
#5958 WriteAndFlushEnrichedTraces net472 880μs 460ns 1.72μs 0.434 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 198μs 1.09μs 7.31μs 0.201 0 0 18.73 KB
master SendRequest netcoreapp3.1 215μs 1.22μs 9.23μs 0.217 0 0 20.89 KB
master SendRequest net472 0.00176ns 0.000556ns 0.00215ns 0 0 0 0 b
#5958 SendRequest net6.0 203μs 1.17μs 9.28μs 0.204 0 0 18.73 KB
#5958 SendRequest netcoreapp3.1 215μs 1.35μs 13.3μs 0.214 0 0 20.89 KB
#5958 SendRequest net472 0.000335ns 0.000275ns 0.000993ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed :heavy_check_mark: Fewer allocations :tada:

Fewer allocations :tada: in #5958

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 41.72 KB 41.46 KB -261 B -0.63%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 585μs 2.74μs 10.2μs 0.566 0 0 41.72 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 674μs 2.36μs 9.13μs 0.331 0 0 41.63 KB
master WriteAndFlushEnrichedTraces net472 853μs 4.17μs 18.7μs 8.19 2.59 0.431 53.26 KB
#5958 WriteAndFlushEnrichedTraces net6.0 565μs 1.99μs 7.71μs 0.568 0 0 41.46 KB
#5958 WriteAndFlushEnrichedTraces netcoreapp3.1 685μs 3.05μs 11.8μs 0.338 0 0 41.74 KB
#5958 WriteAndFlushEnrichedTraces net472 886μs 4.23μs 16.9μs 8.19 2.59 0.431 53.27 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.29μs 1.17ns 4.54ns 0.0142 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.78μs 1.19ns 4.6ns 0.0133 0 0 1.02 KB
master ExecuteNonQuery net472 2.1μs 0.779ns 3.02ns 0.156 0.00105 0 987 B
#5958 ExecuteNonQuery net6.0 1.32μs 1.39ns 5.38ns 0.0139 0 0 1.02 KB
#5958 ExecuteNonQuery netcoreapp3.1 1.73μs 0.919ns 3.31ns 0.014 0 0 1.02 KB
#5958 ExecuteNonQuery net472 2.02μs 1.76ns 6.58ns 0.156 0.00102 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.3μs 0.582ns 2.18ns 0.0137 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.58μs 2.2ns 7.94ns 0.0132 0 0 976 B
master CallElasticsearch net472 2.61μs 1.12ns 4.19ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.21μs 0.535ns 1.93ns 0.0133 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 0.892ns 3.34ns 0.014 0 0 1.02 KB
master CallElasticsearchAsync net472 2.59μs 1.59ns 6.16ns 0.167 0 0 1.05 KB
#5958 CallElasticsearch net6.0 1.29μs 1.87ns 6.99ns 0.0135 0 0 976 B
#5958 CallElasticsearch netcoreapp3.1 1.58μs 0.531ns 1.99ns 0.0132 0 0 976 B
#5958 CallElasticsearch net472 2.6μs 0.978ns 3.79ns 0.157 0 0 995 B
#5958 CallElasticsearchAsync net6.0 1.31μs 0.586ns 2.11ns 0.013 0 0 952 B
#5958 CallElasticsearchAsync netcoreapp3.1 1.56μs 0.947ns 3.54ns 0.0133 0 0 1.02 KB
#5958 CallElasticsearchAsync net472 2.58μs 0.634ns 2.37ns 0.166 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.22μs 0.382ns 1.43ns 0.0136 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.57μs 1.31ns 5.08ns 0.0134 0 0 952 B
master ExecuteAsync net472 1.85μs 2.49ns 9.66ns 0.145 0 0 915 B
#5958 ExecuteAsync net6.0 1.18μs 0.448ns 1.68ns 0.0135 0 0 952 B
#5958 ExecuteAsync netcoreapp3.1 1.62μs 1.04ns 3.88ns 0.013 0 0 952 B
#5958 ExecuteAsync net472 1.88μs 0.781ns 3.02ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.31μs 1.01ns 3.63ns 0.0316 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.4μs 4.82ns 18.7ns 0.0377 0 0 2.85 KB
master SendAsync net472 7.4μs 2.02ns 7.83ns 0.496 0 0 3.12 KB
#5958 SendAsync net6.0 4.39μs 1.27ns 4.74ns 0.0309 0 0 2.31 KB
#5958 SendAsync netcoreapp3.1 5.44μs 2.62ns 9.09ns 0.0384 0 0 2.85 KB
#5958 SendAsync net472 7.38μs 1.63ns 6.33ns 0.495 0 0 3.12 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.56μs 0.656ns 2.54ns 0.0233 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.23μs 0.808ns 3.13ns 0.0221 0 0 1.64 KB
master EnrichedLog net472 2.67μs 1.88ns 7.28ns 0.249 0 0 1.57 KB
#5958 EnrichedLog net6.0 1.54μs 6.23ns 24.1ns 0.0228 0 0 1.64 KB
#5958 EnrichedLog netcoreapp3.1 2.33μs 1ns 3.75ns 0.0218 0 0 1.64 KB
#5958 EnrichedLog net472 2.45μs 0.957ns 3.71ns 0.249 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 119μs 144ns 556ns 0.0587 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 124μs 151ns 585ns 0 0 0 4.28 KB
master EnrichedLog net472 152μs 95.8ns 371ns 0.683 0.228 0 4.46 KB
#5958 EnrichedLog net6.0 119μs 110ns 411ns 0.0592 0 0 4.28 KB
#5958 EnrichedLog netcoreapp3.1 123μs 218ns 846ns 0 0 0 4.28 KB
#5958 EnrichedLog net472 152μs 180ns 696ns 0.678 0.226 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 3.1μs 0.94ns 3.64ns 0.0311 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.12μs 3ns 11.6ns 0.0286 0 0 2.2 KB
master EnrichedLog net472 4.82μs 1.33ns 4.98ns 0.319 0 0 2.02 KB
#5958 EnrichedLog net6.0 2.97μs 0.886ns 3.43ns 0.0311 0 0 2.2 KB
#5958 EnrichedLog netcoreapp3.1 4.22μs 2.44ns 8.79ns 0.0294 0 0 2.2 KB
#5958 EnrichedLog net472 4.9μs 2.28ns 8.81ns 0.32 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.35μs 0.681ns 2.64ns 0.0162 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.77μs 2.44ns 9.46ns 0.0153 0 0 1.14 KB
master SendReceive net472 2.03μs 1.47ns 5.7ns 0.183 0 0 1.16 KB
#5958 SendReceive net6.0 1.38μs 0.734ns 2.84ns 0.0159 0 0 1.14 KB
#5958 SendReceive netcoreapp3.1 1.85μs 0.878ns 3.4ns 0.0156 0 0 1.14 KB
#5958 SendReceive net472 2.02μs 0.756ns 2.73ns 0.183 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.73μs 0.684ns 2.65ns 0.0219 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.95μs 2.19ns 8.49ns 0.0218 0 0 1.65 KB
master EnrichedLog net472 4.47μs 2.07ns 7.76ns 0.322 0 0 2.04 KB
#5958 EnrichedLog net6.0 2.72μs 1.63ns 6.31ns 0.0216 0 0 1.6 KB
#5958 EnrichedLog netcoreapp3.1 3.92μs 11.9ns 46.1ns 0.0212 0 0 1.65 KB
#5958 EnrichedLog net472 4.31μs 1.45ns 5.43ns 0.323 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower :warning: Same allocations :heavy_check_mark:

Slower :warning: in #5958

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net472 1.146 604.71 692.95

Faster :tada: in #5958

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.209 576.22 476.61
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.150 465.83 405.21

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 466ns 0.378ns 1.46ns 0.00815 0 0 576 B
master StartFinishSpan netcoreapp3.1 557ns 0.32ns 1.15ns 0.00781 0 0 576 B
master StartFinishSpan net472 605ns 0.514ns 1.99ns 0.0917 0 0 578 B
master StartFinishScope net6.0 576ns 0.471ns 1.82ns 0.00984 0 0 696 B
master StartFinishScope netcoreapp3.1 708ns 0.97ns 3.76ns 0.00927 0 0 696 B
master StartFinishScope net472 920ns 0.712ns 2.76ns 0.104 0 0 658 B
#5958 StartFinishSpan net6.0 405ns 0.139ns 0.537ns 0.00815 0 0 576 B
#5958 StartFinishSpan netcoreapp3.1 549ns 0.291ns 1.13ns 0.0077 0 0 576 B
#5958 StartFinishSpan net472 693ns 0.628ns 2.43ns 0.0916 0 0 578 B
#5958 StartFinishScope net6.0 477ns 0.175ns 0.633ns 0.00988 0 0 696 B
#5958 StartFinishScope netcoreapp3.1 697ns 0.454ns 1.76ns 0.00947 0 0 696 B
#5958 StartFinishScope net472 844ns 0.825ns 3.2ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 645ns 0.482ns 1.87ns 0.00977 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 880ns 0.617ns 2.23ns 0.00929 0 0 696 B
master RunOnMethodBegin net472 1.21μs 1.17ns 4.52ns 0.105 0 0 658 B
#5958 RunOnMethodBegin net6.0 653ns 0.492ns 1.91ns 0.00963 0 0 696 B
#5958 RunOnMethodBegin netcoreapp3.1 938ns 0.808ns 3.13ns 0.00958 0 0 696 B
#5958 RunOnMethodBegin net472 1.12μs 0.181ns 0.652ns 0.105 0 0 658 B

andrewlock avatar Aug 28 '24 16:08 andrewlock

Throughput/Crank Report :zap:

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 (5958) (11.106M)   : 0, 11105674
    master (11.197M)   : 0, 11197381
    benchmarks/2.9.0 (11.033M)   : 0, 11032866

    section Automatic
    This PR (5958) (7.239M)   : 0, 7238865
    master (7.192M)   : 0, 7192384
    benchmarks/2.9.0 (7.786M)   : 0, 7785853

    section Trace stats
    master (7.476M)   : 0, 7475872

    section Manual
    master (11.271M)   : 0, 11270878

    section Manual + Automatic
    This PR (5958) (6.655M)   : 0, 6655104
    master (6.621M)   : 0, 6620931

    section DD_TRACE_ENABLED=0
    master (10.177M)   : 0, 10176556

gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5958) (9.439M)   : 0, 9438972
    master (9.640M)   : 0, 9639769
    benchmarks/2.9.0 (9.495M)   : 0, 9494821

    section Automatic
    This PR (5958) (6.435M)   : 0, 6434537
    master (6.385M)   : 0, 6384570

    section Trace stats
    master (6.740M)   : 0, 6739552

    section Manual
    master (9.612M)   : 0, 9611974

    section Manual + Automatic
    This PR (5958) (6.000M)   : 0, 5999549
    master (5.891M)   : 0, 5890550

    section DD_TRACE_ENABLED=0
    master (8.839M)   : 0, 8838985

gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5958) (9.925M)   : 0, 9924916
    master (10.121M)   : 0, 10120763
    benchmarks/2.9.0 (10.020M)   : 0, 10019592

    section Automatic
    This PR (5958) (6.519M)   : 0, 6519204
    master (6.469M)   : 0, 6469072
    benchmarks/2.9.0 (7.255M)   : 0, 7255257

    section Trace stats
    master (6.864M)   : 0, 6863851

    section Manual
    master (9.854M)   : 0, 9854162

    section Manual + Automatic
    This PR (5958) (5.779M)   : 0, 5778586
    master (5.906M)   : 0, 5906154

    section DD_TRACE_ENABLED=0
    master (9.224M)   : 0, 9224050

andrewlock avatar Aug 29 '24 12:08 andrewlock