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

Add support for RabbitMQ v7 #6479

Open
wants to merge 8 commits into
base: andrew/value-task-support
Choose a base branch
from

Conversation

andrewlock
Copy link
Member

@andrewlock andrewlock commented Dec 20, 2024

Summary of changes

Adds support for RabbitMQ v7

Reason for change

We want to support the latest versions of packages. 7.x.x was released ~6 weeks ago, with significant changes to both the public API and the internal API (which is probably why it hasn't been explicitly requested yet).

Implementation details

This one took a lot of work. In summary:

  • Basically all the integrations had to be rewritten to work with the new async APIs
    • Where possible, simply called into the original sync integration (other than where the work is trivial)
  • Some challenges, in that the duck types had to change.
    • Most problematic was the BasicProperties because now IReadOnlyBasicProperties is null, which means we can't easily add the headers if they're not provided (to propagate context).
    • Worked around it with an additional instrumentation, but I'm not super happy about it 😅
  • Had to completely rewrite the sample app to use the new async APIs
    • Originally I tried to #if RABBITMQ_7_0 my way in the existing methods, but was impossible to follow, so split into -pre and -post v7 methods instead.
    • Tweaked some of the pre-V7 methods in the sample to be async to improve reuse

Test coverage

We get the same overall snapshots for v7 as we do for v6, so 🤞 Did an "all TFMs, all versions" run here (and a previous one for DSM)

Other details

Stacked on:

Note

This PR actually highlighted a current limitation in our CallTarget instrumentation. If an API uses ValueTask, which comes from a library rather than being built-in (i.e. it's netfx or < .NET Core 3.1) then we don't instrument it correctly. Originally I worked around it, but there's a "proper" fix in #6480. Assuming that actually works and is merged, then we don't need the workaround, otherwise I can re-enable it.

@andrewlock andrewlock added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) labels Dec 20, 2024
@andrewlock andrewlock requested review from a team as code owners December 20, 2024 17:04
@andrewlock
Copy link
Member Author

andrewlock commented Dec 20, 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 (6479) - mean (68ms)  : 66, 70
     .   : milestone, 68,
    master - mean (68ms)  : 66, 71
     .   : milestone, 68,

    section CallTarget+Inlining+NGEN
    This PR (6479) - mean (979ms)  : 948, 1010
     .   : milestone, 979,
    master - mean (978ms)  : 957, 1000
     .   : milestone, 978,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6479) - mean (107ms)  : 104, 110
     .   : milestone, 107,
    master - mean (107ms)  : 104, 109
     .   : milestone, 107,

    section CallTarget+Inlining+NGEN
    This PR (6479) - mean (676ms)  : 659, 693
     .   : milestone, 676,
    master - mean (678ms)  : 664, 693
     .   : milestone, 678,

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

    section CallTarget+Inlining+NGEN
    This PR (6479) - mean (631ms)  : 615, 647
     .   : milestone, 631,
    master - mean (632ms)  : 616, 649
     .   : milestone, 632,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6479) - mean (193ms)  : 189, 198
     .   : milestone, 193,
    master - mean (193ms)  : 189, 198
     .   : milestone, 193,

    section CallTarget+Inlining+NGEN
    This PR (6479) - mean (1,095ms)  : 1070, 1120
     .   : milestone, 1095,
    master - mean (1,095ms)  : 1068, 1122
     .   : milestone, 1095,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6479) - mean (277ms)  : 273, 282
     .   : milestone, 277,
    master - mean (277ms)  : 272, 282
     .   : milestone, 277,

    section CallTarget+Inlining+NGEN
    This PR (6479) - mean (868ms)  : 844, 891
     .   : milestone, 868,
    master - mean (870ms)  : 840, 900
     .   : milestone, 870,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6479) - mean (267ms)  : 262, 273
     .   : milestone, 267,
    master - mean (267ms)  : 262, 271
     .   : milestone, 267,

    section CallTarget+Inlining+NGEN
    This PR (6479) - mean (849ms)  : 809, 889
     .   : milestone, 849,
    master - mean (850ms)  : 816, 883
     .   : milestone, 850,

Loading

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Dec 20, 2024

Datadog Report

Branch report: andrew/update-rabbitmq
Commit report: 882ea95
Test service: dd-trace-dotnet

✅ 0 Failed, 472561 Passed, 3719 Skipped, 32h 58m 48.1s Total Time

@andrewlock
Copy link
Member Author

andrewlock commented Dec 21, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #6479 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.117
  • 1 benchmarks are slower, with geometric mean 1.149
  • 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μs 41.5ns 256ns 0.0159 0.00797 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.1μs 44.2ns 165ns 0.0263 0.0105 0 5.81 KB
master StartStopWithChild net472 16.5μs 47.9ns 185ns 1.06 0.331 0.091 6.2 KB
#6479 StartStopWithChild net6.0 7.95μs 43.3ns 249ns 0.0191 0.00765 0 5.61 KB
#6479 StartStopWithChild netcoreapp3.1 9.99μs 46.7ns 175ns 0.0198 0.00989 0 5.8 KB
#6479 StartStopWithChild net472 16.5μs 60.2ns 225ns 1.06 0.332 0.0972 6.2 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 474μs 443ns 1.72μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 658μs 441ns 1.71μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 846μs 583ns 2.26μs 0.425 0 0 3.3 KB
#6479 WriteAndFlushEnrichedTraces net6.0 514μs 230ns 890ns 0 0 0 2.7 KB
#6479 WriteAndFlushEnrichedTraces netcoreapp3.1 646μs 228ns 852ns 0 0 0 2.7 KB
#6479 WriteAndFlushEnrichedTraces net472 854μs 1.12μs 4.04μs 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 154μs 965ns 9.4μs 0.169 0 0 14.47 KB
master SendRequest netcoreapp3.1 177μs 1.06μs 10.6μs 0.157 0 0 17.27 KB
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#6479 SendRequest net6.0 148μs 859ns 7.83μs 0.143 0 0 14.47 KB
#6479 SendRequest netcoreapp3.1 175μs 1.02μs 9.49μs 0.175 0 0 17.27 KB
#6479 SendRequest net472 0.000782ns 0.000333ns 0.0012ns 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 566μs 2.69μs 12μs 0.563 0 0 41.59 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 667μs 3.8μs 26.6μs 0.331 0 0 41.67 KB
master WriteAndFlushEnrichedTraces net472 820μs 4.1μs 18.4μs 8.69 2.48 0.414 53.32 KB
#6479 WriteAndFlushEnrichedTraces net6.0 569μs 3.16μs 19.2μs 0.561 0 0 41.64 KB
#6479 WriteAndFlushEnrichedTraces netcoreapp3.1 693μs 3.94μs 29μs 0.336 0 0 41.78 KB
#6479 WriteAndFlushEnrichedTraces net472 880μs 3.41μs 13.2μs 8.33 2.5 0.417 53.28 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.34μs 1.12ns 4.35ns 0.014 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.76μs 2.21ns 8.56ns 0.0132 0 0 1.02 KB
master ExecuteNonQuery net472 2.09μs 2ns 7.76ns 0.156 0.00104 0 987 B
#6479 ExecuteNonQuery net6.0 1.23μs 1.15ns 4.47ns 0.0146 0 0 1.02 KB
#6479 ExecuteNonQuery netcoreapp3.1 1.81μs 1.73ns 6.71ns 0.0135 0 0 1.02 KB
#6479 ExecuteNonQuery net472 2.12μs 2.13ns 8.25ns 0.156 0.00106 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.23μs 0.494ns 1.91ns 0.0136 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.5μs 2.82ns 10.9ns 0.0134 0 0 976 B
master CallElasticsearch net472 2.55μs 1.48ns 5.53ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.23μs 0.454ns 1.7ns 0.0135 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.69μs 1.01ns 3.64ns 0.0136 0 0 1.02 KB
master CallElasticsearchAsync net472 2.56μs 2.59ns 10ns 0.167 0 0 1.05 KB
#6479 CallElasticsearch net6.0 1.26μs 0.666ns 2.58ns 0.0138 0 0 976 B
#6479 CallElasticsearch netcoreapp3.1 1.61μs 0.597ns 2.31ns 0.0129 0 0 976 B
#6479 CallElasticsearch net472 2.53μs 1.99ns 7.72ns 0.158 0 0 995 B
#6479 CallElasticsearchAsync net6.0 1.29μs 1.67ns 6.25ns 0.0133 0 0 952 B
#6479 CallElasticsearchAsync netcoreapp3.1 1.77μs 4.54ns 17.6ns 0.0132 0 0 1.02 KB
#6479 CallElasticsearchAsync net472 2.64μs 4.32ns 16.7ns 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.37μs 0.559ns 2.09ns 0.0137 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.69μs 1.13ns 4.21ns 0.0128 0 0 952 B
master ExecuteAsync net472 1.81μs 0.455ns 1.76ns 0.145 0 0 915 B
#6479 ExecuteAsync net6.0 1.25μs 0.645ns 2.41ns 0.0132 0 0 952 B
#6479 ExecuteAsync netcoreapp3.1 1.57μs 6.43ns 24.9ns 0.0126 0 0 952 B
#6479 ExecuteAsync net472 1.8μs 0.678ns 2.54ns 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.33μs 1.38ns 4.97ns 0.0327 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.43μs 1.75ns 6.54ns 0.0381 0 0 2.85 KB
master SendAsync net472 7.36μs 2.66ns 9.94ns 0.492 0 0 3.12 KB
#6479 SendAsync net6.0 4.32μs 1.19ns 4.28ns 0.0324 0 0 2.31 KB
#6479 SendAsync netcoreapp3.1 5.23μs 3.04ns 10.5ns 0.0364 0 0 2.85 KB
#6479 SendAsync net472 7.36μs 2.04ns 7.9ns 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.5μs 0.943ns 3.53ns 0.0233 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.41μs 1.75ns 6.55ns 0.0227 0 0 1.64 KB
master EnrichedLog net472 2.7μs 1.41ns 5.45ns 0.249 0 0 1.57 KB
#6479 EnrichedLog net6.0 1.61μs 0.728ns 2.82ns 0.0232 0 0 1.64 KB
#6479 EnrichedLog netcoreapp3.1 2.24μs 0.55ns 1.98ns 0.0224 0 0 1.64 KB
#6479 EnrichedLog net472 2.65μs 0.76ns 2.94ns 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 115μs 131ns 508ns 0.058 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 124μs 200ns 776ns 0 0 0 4.28 KB
master EnrichedLog net472 150μs 242ns 937ns 0.677 0.226 0 4.46 KB
#6479 EnrichedLog net6.0 115μs 143ns 554ns 0.0572 0 0 4.28 KB
#6479 EnrichedLog netcoreapp3.1 121μs 328ns 1.27μs 0 0 0 4.28 KB
#6479 EnrichedLog net472 153μs 186ns 721ns 0.684 0.228 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 2.98μs 0.781ns 3.03ns 0.0298 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.22μs 1.5ns 5.4ns 0.0295 0 0 2.2 KB
master EnrichedLog net472 4.83μs 1.05ns 4.06ns 0.319 0 0 2.02 KB
#6479 EnrichedLog net6.0 3.07μs 1.48ns 5.72ns 0.0311 0 0 2.2 KB
#6479 EnrichedLog netcoreapp3.1 4.29μs 3.11ns 12ns 0.0298 0 0 2.2 KB
#6479 EnrichedLog net472 5.02μs 1.32ns 5.11ns 0.32 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.42μs 0.335ns 1.25ns 0.0163 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.85μs 0.584ns 2.18ns 0.0155 0 0 1.14 KB
master SendReceive net472 2.02μs 1.76ns 6.83ns 0.183 0 0 1.16 KB
#6479 SendReceive net6.0 1.44μs 0.913ns 3.54ns 0.0157 0 0 1.14 KB
#6479 SendReceive netcoreapp3.1 1.82μs 1.14ns 4.43ns 0.0154 0 0 1.14 KB
#6479 SendReceive net472 2.06μs 1.57ns 5.86ns 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.74μs 0.813ns 3.15ns 0.0233 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4.07μs 2.35ns 8.78ns 0.0224 0 0 1.65 KB
master EnrichedLog net472 4.32μs 3.1ns 11.6ns 0.322 0 0 2.04 KB
#6479 EnrichedLog net6.0 2.75μs 1.12ns 4.17ns 0.022 0 0 1.6 KB
#6479 EnrichedLog netcoreapp3.1 3.96μs 1.05ns 3.94ns 0.0217 0 0 1.65 KB
#6479 EnrichedLog net472 4.32μs 3.39ns 12.7ns 0.323 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6479

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.149 393.72 452.26

Faster 🎉 in #6479

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 1.117 624.85 559.48

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 394ns 0.22ns 0.852ns 0.00808 0 0 576 B
master StartFinishSpan netcoreapp3.1 625ns 0.695ns 2.6ns 0.00764 0 0 576 B
master StartFinishSpan net472 658ns 0.454ns 1.76ns 0.0917 0 0 578 B
master StartFinishScope net6.0 481ns 0.199ns 0.769ns 0.00982 0 0 696 B
master StartFinishScope netcoreapp3.1 729ns 1.06ns 4.11ns 0.00949 0 0 696 B
master StartFinishScope net472 846ns 0.376ns 1.36ns 0.104 0 0 658 B
#6479 StartFinishSpan net6.0 452ns 0.193ns 0.722ns 0.00819 0 0 576 B
#6479 StartFinishSpan netcoreapp3.1 560ns 0.406ns 1.52ns 0.00785 0 0 576 B
#6479 StartFinishSpan net472 661ns 0.269ns 1.04ns 0.0916 0 0 578 B
#6479 StartFinishScope net6.0 484ns 0.267ns 1.04ns 0.00972 0 0 696 B
#6479 StartFinishScope netcoreapp3.1 803ns 0.427ns 1.65ns 0.00951 0 0 696 B
#6479 StartFinishScope net472 928ns 0.277ns 1.07ns 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 640ns 1.74ns 6.75ns 0.00959 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 897ns 1.04ns 4.02ns 0.00942 0 0 696 B
master RunOnMethodBegin net472 1.05μs 0.815ns 3.16ns 0.104 0 0 658 B
#6479 RunOnMethodBegin net6.0 584ns 0.26ns 0.937ns 0.00969 0 0 696 B
#6479 RunOnMethodBegin netcoreapp3.1 916ns 0.779ns 3.02ns 0.00936 0 0 696 B
#6479 RunOnMethodBegin net472 1.12μs 0.768ns 2.98ns 0.104 0 0 658 B

@andrewlock andrewlock changed the base branch from master to andrew/value-task-support December 23, 2024 15:20
@andrewlock andrewlock force-pushed the andrew/update-rabbitmq branch from c47a319 to c2b1675 Compare December 23, 2024 15:20
@andrewlock andrewlock force-pushed the andrew/value-task-support branch from ffc922e to 457a93f Compare December 23, 2024 17:06
@andrewlock andrewlock force-pushed the andrew/update-rabbitmq branch from c2b1675 to 288fb51 Compare December 23, 2024 17:06
@andrewlock andrewlock force-pushed the andrew/value-task-support branch from 457a93f to 6c8dbe5 Compare December 30, 2024 09:47
@andrewlock andrewlock force-pushed the andrew/update-rabbitmq branch from 288fb51 to 882ea95 Compare December 30, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant