-
Notifications
You must be signed in to change notification settings - Fork 147
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 CallTarget support for ValueTask
in .NET FX and < .NET Core 3.1
#6480
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 234987 Passed, 2074 Skipped, 18h 31m 10.03s Total Time |
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:
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 (6480) - mean (68ms) : 66, 71
. : milestone, 68,
master - mean (69ms) : 66, 72
. : milestone, 69,
section CallTarget+Inlining+NGEN
This PR (6480) - mean (978ms) : 955, 1002
. : milestone, 978,
master - mean (981ms) : 954, 1008
. : milestone, 981,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6480) - mean (107ms) : 105, 110
. : milestone, 107,
master - mean (107ms) : 105, 110
. : milestone, 107,
section CallTarget+Inlining+NGEN
This PR (6480) - mean (676ms) : 661, 690
. : milestone, 676,
master - mean (678ms) : 662, 695
. : milestone, 678,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6480) - mean (91ms) : 89, 93
. : milestone, 91,
master - mean (91ms) : 90, 93
. : milestone, 91,
section CallTarget+Inlining+NGEN
This PR (6480) - mean (630ms) : 613, 647
. : milestone, 630,
master - mean (633ms) : 616, 651
. : milestone, 633,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6480) - mean (194ms) : 190, 198
. : milestone, 194,
master - mean (195ms) : 189, 202
. : milestone, 195,
section CallTarget+Inlining+NGEN
This PR (6480) - mean (1,099ms) : 1064, 1133
. : milestone, 1099,
master - mean (1,104ms) : 1076, 1132
. : milestone, 1104,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6480) - mean (277ms) : 272, 282
. : milestone, 277,
master - mean (278ms) : 273, 282
. : milestone, 278,
section CallTarget+Inlining+NGEN
This PR (6480) - mean (869ms) : 838, 901
. : milestone, 869,
master - mean (874ms) : 847, 901
. : milestone, 874,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6480) - mean (267ms) : 264, 270
. : milestone, 267,
master - mean (268ms) : 264, 272
. : milestone, 268,
section CallTarget+Inlining+NGEN
This PR (6480) - mean (848ms) : 815, 881
. : milestone, 848,
master - mean (857ms) : 829, 885
. : milestone, 857,
|
ffc922e
to
457a93f
Compare
Benchmarks Report for tracer 🐌Benchmarks for #6480 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Slower
|
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch‑net6.0 | 1.161 | 1,158.77 | 1,345.44 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | CallElasticsearch |
net6.0 | 1.16μs | 0.665ns | 2.49ns | 0.0139 | 0 | 0 | 976 B |
master | CallElasticsearch |
netcoreapp3.1 | 1.54μs | 1.66ns | 6.21ns | 0.0132 | 0 | 0 | 976 B |
master | CallElasticsearch |
net472 | 2.53μs | 2.45ns | 9.16ns | 0.158 | 0 | 0 | 995 B |
master | CallElasticsearchAsync |
net6.0 | 1.23μs | 0.618ns | 2.31ns | 0.013 | 0 | 0 | 952 B |
master | CallElasticsearchAsync |
netcoreapp3.1 | 1.69μs | 0.65ns | 2.43ns | 0.0136 | 0 | 0 | 1.02 KB |
master | CallElasticsearchAsync |
net472 | 2.68μs | 1.79ns | 6.94ns | 0.167 | 0 | 0 | 1.05 KB |
#6480 | CallElasticsearch |
net6.0 | 1.35μs | 0.508ns | 1.97ns | 0.0133 | 0 | 0 | 976 B |
#6480 | CallElasticsearch |
netcoreapp3.1 | 1.54μs | 1.09ns | 4.07ns | 0.013 | 0 | 0 | 976 B |
#6480 | CallElasticsearch |
net472 | 2.58μs | 1.72ns | 6.2ns | 0.158 | 0 | 0 | 995 B |
#6480 | CallElasticsearchAsync |
net6.0 | 1.25μs | 0.464ns | 1.8ns | 0.0132 | 0 | 0 | 952 B |
#6480 | CallElasticsearchAsync |
netcoreapp3.1 | 1.58μs | 0.774ns | 2.9ns | 0.0134 | 0 | 0 | 1.02 KB |
#6480 | CallElasticsearchAsync |
net472 | 2.68μs | 1.5ns | 5.6ns | 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.28μs | 0.864ns | 3.23ns | 0.0134 | 0 | 0 | 952 B |
master | ExecuteAsync |
netcoreapp3.1 | 1.65μs | 0.581ns | 2.18ns | 0.0124 | 0 | 0 | 952 B |
master | ExecuteAsync |
net472 | 1.82μs | 1.09ns | 3.78ns | 0.145 | 0 | 0 | 915 B |
#6480 | ExecuteAsync |
net6.0 | 1.36μs | 1.24ns | 4.65ns | 0.0134 | 0 | 0 | 952 B |
#6480 | ExecuteAsync |
netcoreapp3.1 | 1.57μs | 0.677ns | 2.53ns | 0.0126 | 0 | 0 | 952 B |
#6480 | ExecuteAsync |
net472 | 1.76μs | 0.614ns | 2.3ns | 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.45μs | 1.73ns | 6.68ns | 0.0315 | 0 | 0 | 2.31 KB |
master | SendAsync |
netcoreapp3.1 | 5.29μs | 2.82ns | 10.9ns | 0.0371 | 0 | 0 | 2.85 KB |
master | SendAsync |
net472 | 7.36μs | 3.05ns | 11ns | 0.494 | 0 | 0 | 3.12 KB |
#6480 | SendAsync |
net6.0 | 4.45μs | 1.88ns | 7.28ns | 0.031 | 0 | 0 | 2.31 KB |
#6480 | SendAsync |
netcoreapp3.1 | 5.24μs | 1.21ns | 4.54ns | 0.0367 | 0 | 0 | 2.85 KB |
#6480 | SendAsync |
net472 | 7.35μs | 1.71ns | 6.62ns | 0.494 | 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.54μs | 0.653ns | 2.45ns | 0.0231 | 0 | 0 | 1.64 KB |
master | EnrichedLog |
netcoreapp3.1 | 2.09μs | 0.997ns | 3.73ns | 0.0225 | 0 | 0 | 1.64 KB |
master | EnrichedLog |
net472 | 2.69μs | 2.29ns | 8.57ns | 0.249 | 0 | 0 | 1.57 KB |
#6480 | EnrichedLog |
net6.0 | 1.53μs | 2.21ns | 8.57ns | 0.0232 | 0 | 0 | 1.64 KB |
#6480 | EnrichedLog |
netcoreapp3.1 | 2.22μs | 1.22ns | 4.73ns | 0.0216 | 0 | 0 | 1.64 KB |
#6480 | EnrichedLog |
net472 | 2.72μs | 1.61ns | 6.23ns | 0.248 | 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 | 118μs | 195ns | 756ns | 0 | 0 | 0 | 4.28 KB |
master | EnrichedLog |
netcoreapp3.1 | 120μs | 164ns | 635ns | 0.0603 | 0 | 0 | 4.28 KB |
master | EnrichedLog |
net472 | 151μs | 173ns | 648ns | 0.671 | 0.224 | 0 | 4.46 KB |
#6480 | EnrichedLog |
net6.0 | 119μs | 258ns | 1E+03ns | 0.0593 | 0 | 0 | 4.28 KB |
#6480 | EnrichedLog |
netcoreapp3.1 | 120μs | 210ns | 814ns | 0 | 0 | 0 | 4.28 KB |
#6480 | EnrichedLog |
net472 | 152μs | 120ns | 465ns | 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.92μs | 1.13ns | 4.38ns | 0.0306 | 0 | 0 | 2.2 KB |
master | EnrichedLog |
netcoreapp3.1 | 4.2μs | 1.84ns | 6.88ns | 0.0294 | 0 | 0 | 2.2 KB |
master | EnrichedLog |
net472 | 4.88μs | 1.69ns | 6.54ns | 0.319 | 0 | 0 | 2.02 KB |
#6480 | EnrichedLog |
net6.0 | 3.12μs | 3.15ns | 12.2ns | 0.0308 | 0 | 0 | 2.2 KB |
#6480 | EnrichedLog |
netcoreapp3.1 | 4.42μs | 1.82ns | 7.05ns | 0.0287 | 0 | 0 | 2.2 KB |
#6480 | EnrichedLog |
net472 | 4.89μs | 0.664ns | 2.57ns | 0.319 | 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.41μs | 0.818ns | 3.17ns | 0.0162 | 0 | 0 | 1.14 KB |
master | SendReceive |
netcoreapp3.1 | 1.76μs | 0.633ns | 2.28ns | 0.0152 | 0 | 0 | 1.14 KB |
master | SendReceive |
net472 | 2.13μs | 1.58ns | 5.92ns | 0.184 | 0 | 0 | 1.16 KB |
#6480 | SendReceive |
net6.0 | 1.37μs | 0.634ns | 2.29ns | 0.0158 | 0 | 0 | 1.14 KB |
#6480 | SendReceive |
netcoreapp3.1 | 1.8μs | 0.627ns | 2.35ns | 0.0152 | 0 | 0 | 1.14 KB |
#6480 | SendReceive |
net472 | 2.16μs | 0.993ns | 3.58ns | 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.79μs | 0.881ns | 3.3ns | 0.0223 | 0 | 0 | 1.6 KB |
master | EnrichedLog |
netcoreapp3.1 | 3.95μs | 1.6ns | 6.19ns | 0.0219 | 0 | 0 | 1.65 KB |
master | EnrichedLog |
net472 | 4.24μs | 3.28ns | 11.8ns | 0.322 | 0 | 0 | 2.04 KB |
#6480 | EnrichedLog |
net6.0 | 2.77μs | 1.7ns | 6.37ns | 0.022 | 0 | 0 | 1.6 KB |
#6480 | EnrichedLog |
netcoreapp3.1 | 3.86μs | 2.39ns | 9.26ns | 0.0213 | 0 | 0 | 1.65 KB |
#6480 | EnrichedLog |
net472 | 4.5μs | 3.32ns | 12.9ns | 0.322 | 0 | 0 | 2.04 KB |
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #6480
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1
1.206
538.86
650.01
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0
1.126
402.00
452.76
Faster 🎉 in #6480
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0
1.127
562.66
499.30
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 | 1.206 | 538.86 | 650.01 | |
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 | 1.126 | 402.00 | 452.76 |
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 | 1.127 | 562.66 | 499.30 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StartFinishSpan |
net6.0 | 402ns | 0.511ns | 1.98ns | 0.0081 | 0 | 0 | 576 B |
master | StartFinishSpan |
netcoreapp3.1 | 539ns | 0.687ns | 2.66ns | 0.00777 | 0 | 0 | 576 B |
master | StartFinishSpan |
net472 | 650ns | 1.43ns | 5.56ns | 0.0917 | 0 | 0 | 578 B |
master | StartFinishScope |
net6.0 | 563ns | 0.836ns | 3.24ns | 0.00971 | 0 | 0 | 696 B |
master | StartFinishScope |
netcoreapp3.1 | 713ns | 1.11ns | 4.31ns | 0.00965 | 0 | 0 | 696 B |
master | StartFinishScope |
net472 | 885ns | 1.17ns | 4.53ns | 0.104 | 0 | 0 | 658 B |
#6480 | StartFinishSpan |
net6.0 | 453ns | 0.36ns | 1.3ns | 0.00806 | 0 | 0 | 576 B |
#6480 | StartFinishSpan |
netcoreapp3.1 | 650ns | 1.05ns | 4.08ns | 0.0077 | 0 | 0 | 576 B |
#6480 | StartFinishSpan |
net472 | 617ns | 1.16ns | 4.49ns | 0.0918 | 0 | 0 | 578 B |
#6480 | StartFinishScope |
net6.0 | 499ns | 0.459ns | 1.78ns | 0.00969 | 0 | 0 | 696 B |
#6480 | StartFinishScope |
netcoreapp3.1 | 677ns | 1.08ns | 4.18ns | 0.00915 | 0 | 0 | 696 B |
#6480 | StartFinishScope |
net472 | 830ns | 1.47ns | 5.7ns | 0.104 | 0 | 0 | 658 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #6480
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0
1.120
600.43
672.69
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 | 1.120 | 600.43 | 672.69 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | RunOnMethodBegin |
net6.0 | 600ns | 1.14ns | 4.4ns | 0.00973 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
netcoreapp3.1 | 896ns | 1.28ns | 4.96ns | 0.00933 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
net472 | 1.09μs | 1.93ns | 7.46ns | 0.104 | 0 | 0 | 658 B |
#6480 | RunOnMethodBegin |
net6.0 | 671ns | 1.61ns | 6.03ns | 0.00985 | 0 | 0 | 696 B |
#6480 | RunOnMethodBegin |
netcoreapp3.1 | 993ns | 1.02ns | 3.97ns | 0.00935 | 0 | 0 | 696 B |
#6480 | RunOnMethodBegin |
net472 | 1.13μs | 1.7ns | 6.59ns | 0.104 | 0 | 0 | 658 B |
457a93f
to
6c8dbe5
Compare
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 (6480) (11.113M) : 0, 11112891
master (11.278M) : 0, 11278464
benchmarks/2.9.0 (11.144M) : 0, 11143547
section Automatic
This PR (6480) (7.431M) : 0, 7431434
master (7.310M) : 0, 7310284
benchmarks/2.9.0 (7.982M) : 0, 7981525
section Trace stats
master (7.466M) : 0, 7466025
section Manual
master (11.098M) : 0, 11098414
section Manual + Automatic
This PR (6480) (6.769M) : 0, 6769440
master (6.596M) : 0, 6596135
section DD_TRACE_ENABLED=0
master (10.177M) : 0, 10177094
gantt
title Throughput Linux arm64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6480) (9.563M) : 0, 9563388
master (9.615M) : 0, 9615070
benchmarks/2.9.0 (9.621M) : 0, 9621397
section Automatic
This PR (6480) (6.501M) : 0, 6500795
master (6.452M) : 0, 6452148
section Trace stats
master (6.369M) : 0, 6369273
section Manual
master (9.539M) : 0, 9539051
section Manual + Automatic
This PR (6480) (5.924M) : 0, 5924116
master (6.003M) : 0, 6003427
section DD_TRACE_ENABLED=0
master (8.846M) : 0, 8846180
gantt
title Throughput Windows x64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6480) (10.316M) : 0, 10316293
master (9.954M) : 0, 9954268
section Automatic
This PR (6480) (6.707M) : 0, 6706701
master (6.674M) : 0, 6674018
section Trace stats
master (7.283M) : 0, 7282769
section Manual
master (10.371M) : 0, 10370838
section Manual + Automatic
This PR (6480) (6.238M) : 0, 6237748
master (6.188M) : 0, 6187851
section DD_TRACE_ENABLED=0
master (9.569M) : 0, 9568617
|
Initially we wrote the Task integration in such a way to avoid declaring |
var unwrappedResult = previousValueTask.Result; | ||
_continuation(instance, unwrappedResult, exception, in state); | ||
return returnValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern is that here we are consuming the result of the value task, and returning the same value task. I guess it's ok, but looks like a double usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh, yeah, good spot, that's not OK:
- Awaiting the instance multiple times.
- Calling AsTask multiple times.
- Using .Result or .GetAwaiter().GetResult() when the operation hasn't yet completed, or using them multiple times.
- Using more than one of these techniques to consume the instance.
I think we need to create a new instance here, e.g.
var unwrappedResult = previousValueTask.Result; | |
_continuation(instance, unwrappedResult, exception, in state); | |
return returnValue; | |
var unwrappedResult = previousValueTask.Result; | |
_continuation(instance, unwrappedResult, exception, in state); | |
return ValueTaskActivator<TReturn, TResult?>.CreateInstance(unwrappedResult); |
(above doesn't compile yet, need to expose the CreateInstance
that takes a result)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a73c2c7
6c8dbe5
to
a73c2c7
Compare
## 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](https://dev.azure.com/datadoghq/dd-trace-dotnet/_build/results?buildId=170428&view=results) (and a previous one for DSM) ## Other details Stacked on: - #6463 - #6480 > [!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.
Summary of changes
Add support for correct
CallTarget
instrumentation of methods that returnValueTask
in < .NET Core 3.1 or .NET FrameworkReason for change
We already support instrumenting methods that returns
ValueTask
in .NET Core 3.1. However, in .NET Framework or .NET Standard 2.0, this support is provided by a package, and we currently don't support instrumenting these methods. Or rather, we just ignore theOnAsyncMethodEnd
in integrations in these cases.Implementation details
We already support
ValueTask
in more recent frameworks, and the support is very similar to ourTask
support. Unfortunately, in .NET FX we can't reference theValueTask
type itself.To work around this, we do the following:
ValueTask
orValueTask<T>
either by loading the type directly (.NET Core) or checking the type name (.NET Framework)ValueTask
to read theIsCompletedSuccessfully
value.ValueTask<T>
we duck typeResult
and read that directly too.Task
from it.Task()
for uncompletedValueTask
Task
integrationsValueTask
instead from the previous oneValueTask
require that we create a "fresh" one, we can't just "reuse" the one we got originally, because we've already retrieved the result/ awaited the inner taskActivator
/DynamicMethod
for thisWarning
The existing
ValueTask
/ValueTask<>
andTask
/Task<>
integrations are written quite differently, and I'm not entirely sure why 🤔 Given theContinuationAction()
methods for both these cases operate onTask
, I based on the newValueTask
integrations on theTask
integrations, but if anyone has reasons why it shouldn't be, I'm all ears!Test coverage
Task
andValueTask
tests to theCallTargetNativeTests
integration tests. Previously we were only testing a singleTask
example, and that was somewhat insufficientCallTargetNativeTests
to explicitly assert that theOnAsyncMethodEnd
methods are called forTask
/ValueTask
method integrations. As we provide both methods in our target integration, we were silently calling the wrong one for .NET FXValueTaskAsyncContinutationGenerator
unit tests on all TFMs, not just .NET Core 3.1ValueTaskHelper
for checking if a type is aValueTask
ValueTaskActivator
for creating aValueTask
from aTask
orTask<T>
Other details
Required for