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 Microsoft.Azure.Functions.Worker.Core v2 #6472

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bouwkast
Copy link
Contributor

@bouwkast bouwkast commented Dec 19, 2024

Summary of changes

Adds support for Microsoft.Azure.Functions.Worker.Core V2.

Reason for change

A new major version of it was released and instrumentations stopped at V1.

Implementation details

Test coverage

I relied on CI to run the tests 🙃
Noticed that the snapshots exception message in the span changed unsure why

Other details

I noticed this old PR #6203 I'm unsure if this impacts this?
Fixes DataDog/datadog-aas-extension#295

https://datadoghq.atlassian.net/browse/AIDM-518
https://datadoghq.atlassian.net/browse/AIDM-519

@andrewlock
Copy link
Member

andrewlock commented Dec 19, 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 (6472) - mean (68ms)  : 65, 72
     .   : milestone, 68,
    master - mean (71ms)  : 60, 82
     .   : milestone, 71,

    section CallTarget+Inlining+NGEN
    This PR (6472) - mean (976ms)  : 951, 1001
     .   : milestone, 976,
    master - mean (981ms)  : 956, 1005
     .   : milestone, 981,

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

    section CallTarget+Inlining+NGEN
    This PR (6472) - mean (669ms)  : 649, 690
     .   : milestone, 669,
    master - mean (680ms)  : 665, 695
     .   : milestone, 680,

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

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

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

    section CallTarget+Inlining+NGEN
    This PR (6472) - mean (1,101ms)  : 1063, 1138
     .   : milestone, 1101,
    master - mean (1,101ms)  : 1075, 1127
     .   : milestone, 1101,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6472) - mean (279ms)  : 274, 284
     .   : milestone, 279,
    master - mean (279ms)  : 275, 283
     .   : milestone, 279,

    section CallTarget+Inlining+NGEN
    This PR (6472) - mean (868ms)  : 838, 897
     .   : milestone, 868,
    master - mean (874ms)  : 844, 904
     .   : milestone, 874,

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

    section CallTarget+Inlining+NGEN
    This PR (6472) - mean (853ms)  : 816, 890
     .   : milestone, 853,
    master - mean (856ms)  : 821, 891
     .   : milestone, 856,

Loading

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Dec 19, 2024

Datadog Report

Branch report: steven/azure-worker-v2
Commit report: 755967c
Test service: dd-trace-dotnet

✅ 0 Failed, 236983 Passed, 2923 Skipped, 31h 56m 54.47s Total Time

Copy link
Contributor

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.

@andrewlock
Copy link
Member

andrewlock commented Dec 19, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #6472 compared to master:

  • 2 benchmarks are faster, with geometric mean 1.146
  • 3 benchmarks are slower, with geometric mean 1.161
  • 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.3μs 47.3ns 335ns 0.0193 0.00773 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.2μs 55.2ns 292ns 0.0154 0.00514 0 5.8 KB
master StartStopWithChild net472 16.6μs 65.3ns 253ns 1.04 0.296 0.0905 6.22 KB
#6472 StartStopWithChild net6.0 8.15μs 45.9ns 301ns 0.0162 0.00811 0 5.61 KB
#6472 StartStopWithChild netcoreapp3.1 10.2μs 55.3ns 303ns 0.0254 0.0102 0 5.8 KB
#6472 StartStopWithChild net472 16.4μs 56ns 217ns 1.05 0.315 0.097 6.22 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 483μs 409ns 1.58μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 688μs 233ns 873ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 857μs 484ns 1.81μs 0.431 0 0 3.3 KB
#6472 WriteAndFlushEnrichedTraces net6.0 483μs 215ns 805ns 0 0 0 2.7 KB
#6472 WriteAndFlushEnrichedTraces netcoreapp3.1 646μs 647ns 2.51μs 0 0 0 2.7 KB
#6472 WriteAndFlushEnrichedTraces net472 862μs 519ns 2.01μ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 935ns 9.25μs 0.168 0 0 14.47 KB
master SendRequest netcoreapp3.1 186μs 1.78μs 17.7μs 0.175 0 0 17.27 KB
master SendRequest net472 0.00291ns 0.00119ns 0.00462ns 0 0 0 0 b
#6472 SendRequest net6.0 156μs 1.02μs 10μs 0.139 0 0 14.47 KB
#6472 SendRequest netcoreapp3.1 180μs 1.13μs 11.2μs 0.161 0 0 17.27 KB
#6472 SendRequest net472 0.00186ns 0.000832ns 0.00311ns 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 587μs 3.32μs 21.8μs 0.291 0 0 41.66 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 672μs 3.63μs 19.5μs 0.388 0 0 41.81 KB
master WriteAndFlushEnrichedTraces net472 834μs 3.96μs 15.3μs 8.45 2.53 0.422 53.28 KB
#6472 WriteAndFlushEnrichedTraces net6.0 574μs 2.84μs 15μs 0.536 0 0 41.64 KB
#6472 WriteAndFlushEnrichedTraces netcoreapp3.1 676μs 3.69μs 26.8μs 0.401 0 0 41.96 KB
#6472 WriteAndFlushEnrichedTraces net472 855μs 4.16μs 17.1μs 8.22 2.47 0.411 53.32 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.3μs 1.36ns 5.28ns 0.0144 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.71μs 2.06ns 7.71ns 0.0133 0 0 1.02 KB
master ExecuteNonQuery net472 2.1μs 2.58ns 10ns 0.156 0.00106 0 987 B
#6472 ExecuteNonQuery net6.0 1.34μs 1.84ns 7.11ns 0.014 0 0 1.02 KB
#6472 ExecuteNonQuery netcoreapp3.1 1.79μs 1.17ns 4.38ns 0.0133 0 0 1.02 KB
#6472 ExecuteNonQuery net472 2.13μs 2.41ns 9.32ns 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.3μs 1.81ns 6.77ns 0.0134 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.52μs 2.42ns 9.36ns 0.013 0 0 976 B
master CallElasticsearch net472 2.47μs 1.18ns 4.43ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.3μs 0.441ns 1.65ns 0.013 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.6μs 0.577ns 2.16ns 0.0136 0 0 1.02 KB
master CallElasticsearchAsync net472 2.6μs 0.815ns 2.82ns 0.167 0 0 1.05 KB
#6472 CallElasticsearch net6.0 1.28μs 0.693ns 2.59ns 0.0135 0 0 976 B
#6472 CallElasticsearch netcoreapp3.1 1.61μs 0.671ns 2.6ns 0.0128 0 0 976 B
#6472 CallElasticsearch net472 2.53μs 1.44ns 5.57ns 0.158 0 0 995 B
#6472 CallElasticsearchAsync net6.0 1.31μs 0.714ns 2.57ns 0.0136 0 0 952 B
#6472 CallElasticsearchAsync netcoreapp3.1 1.63μs 0.936ns 3.62ns 0.0139 0 0 1.02 KB
#6472 CallElasticsearchAsync net472 2.67μs 1.68ns 6.51ns 0.166 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.395ns 1.42ns 0.013 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.65μs 0.859ns 3.33ns 0.0124 0 0 952 B
master ExecuteAsync net472 1.82μs 0.896ns 3.47ns 0.145 0 0 915 B
#6472 ExecuteAsync net6.0 1.32μs 1.02ns 3.95ns 0.0133 0 0 952 B
#6472 ExecuteAsync netcoreapp3.1 1.67μs 1.52ns 5.89ns 0.0126 0 0 952 B
#6472 ExecuteAsync net472 1.79μs 0.531ns 2.06ns 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.46μs 1.65ns 6.37ns 0.0314 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.4μs 1.84ns 7.13ns 0.0379 0 0 2.85 KB
master SendAsync net472 7.61μs 1.62ns 6.29ns 0.493 0 0 3.12 KB
#6472 SendAsync net6.0 4.5μs 1.68ns 6.28ns 0.0315 0 0 2.31 KB
#6472 SendAsync netcoreapp3.1 5.36μs 1.98ns 7.66ns 0.0376 0 0 2.85 KB
#6472 SendAsync net472 7.38μs 1.59ns 6.16ns 0.492 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.48μs 0.708ns 2.65ns 0.0229 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.2μs 1.25ns 4.69ns 0.022 0 0 1.64 KB
master EnrichedLog net472 2.65μs 2.56ns 9.93ns 0.249 0 0 1.57 KB
#6472 EnrichedLog net6.0 1.5μs 0.521ns 1.88ns 0.0227 0 0 1.64 KB
#6472 EnrichedLog netcoreapp3.1 2.22μs 0.864ns 3.23ns 0.0221 0 0 1.64 KB
#6472 EnrichedLog net472 2.83μs 1.65ns 6.19ns 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 119μs 135ns 525ns 0.059 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 121μs 157ns 607ns 0 0 0 4.28 KB
master EnrichedLog net472 150μs 114ns 426ns 0.677 0.226 0 4.46 KB
#6472 EnrichedLog net6.0 116μs 286ns 1.11μs 0.0581 0 0 4.28 KB
#6472 EnrichedLog netcoreapp3.1 122μs 251ns 972ns 0 0 0 4.28 KB
#6472 EnrichedLog net472 151μs 412ns 1.6μs 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.91μs 0.908ns 3.52ns 0.0306 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.36μs 2.3ns 8.61ns 0.0284 0 0 2.2 KB
master EnrichedLog net472 4.86μs 1.99ns 7.69ns 0.321 0 0 2.02 KB
#6472 EnrichedLog net6.0 2.96μs 1.11ns 4.32ns 0.031 0 0 2.2 KB
#6472 EnrichedLog netcoreapp3.1 4.1μs 1.95ns 7.56ns 0.0287 0 0 2.2 KB
#6472 EnrichedLog net472 4.84μs 1.27ns 4.92ns 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.41μs 0.66ns 2.56ns 0.0162 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.73μs 0.74ns 2.86ns 0.0156 0 0 1.14 KB
master SendReceive net472 2.09μs 0.989ns 3.83ns 0.184 0 0 1.16 KB
#6472 SendReceive net6.0 1.39μs 0.556ns 2.15ns 0.0159 0 0 1.14 KB
#6472 SendReceive netcoreapp3.1 1.72μs 1.18ns 4.56ns 0.0155 0 0 1.14 KB
#6472 SendReceive net472 2.19μs 0.895ns 3.47ns 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.67μs 0.721ns 2.79ns 0.0227 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.84μs 0.924ns 3.2ns 0.0211 0 0 1.65 KB
master EnrichedLog net472 4.39μs 1.53ns 5.71ns 0.323 0 0 2.04 KB
#6472 EnrichedLog net6.0 2.75μs 0.513ns 1.99ns 0.022 0 0 1.6 KB
#6472 EnrichedLog netcoreapp3.1 3.88μs 2.25ns 8.7ns 0.0214 0 0 1.65 KB
#6472 EnrichedLog net472 4.31μs 10.1ns 39.1ns 0.323 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6472

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.135 481.21 546.32

Faster 🎉 in #6472

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net472 1.154 961.33 832.93
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 1.138 808.11 710.06

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 399ns 0.229ns 0.887ns 0.00804 0 0 576 B
master StartFinishSpan netcoreapp3.1 610ns 0.455ns 1.7ns 0.00768 0 0 576 B
master StartFinishSpan net472 742ns 0.301ns 1.17ns 0.0915 0 0 578 B
master StartFinishScope net6.0 481ns 0.279ns 1.08ns 0.00991 0 0 696 B
master StartFinishScope netcoreapp3.1 808ns 0.536ns 2.08ns 0.00929 0 0 696 B
master StartFinishScope net472 961ns 0.532ns 2.06ns 0.104 0 0 658 B
#6472 StartFinishSpan net6.0 392ns 0.184ns 0.688ns 0.0081 0 0 576 B
#6472 StartFinishSpan netcoreapp3.1 670ns 0.521ns 1.8ns 0.00761 0 0 576 B
#6472 StartFinishSpan net472 713ns 0.43ns 1.67ns 0.0918 0 0 578 B
#6472 StartFinishScope net6.0 546ns 0.255ns 0.953ns 0.00973 0 0 696 B
#6472 StartFinishScope netcoreapp3.1 710ns 0.294ns 1.14ns 0.00933 0 0 696 B
#6472 StartFinishScope net472 832ns 0.842ns 3.26ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6472

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 1.187 588.32 698.05
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑netcoreapp3.1 1.162 857.63 996.24

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 588ns 0.358ns 1.38ns 0.00986 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 858ns 0.299ns 1.12ns 0.00947 0 0 696 B
master RunOnMethodBegin net472 1.14μs 0.509ns 1.97ns 0.104 0 0 658 B
#6472 RunOnMethodBegin net6.0 698ns 0.721ns 2.79ns 0.00983 0 0 696 B
#6472 RunOnMethodBegin netcoreapp3.1 998ns 1.16ns 4.19ns 0.0095 0 0 696 B
#6472 RunOnMethodBegin net472 1.12μs 1.11ns 4.31ns 0.104 0 0 658 B

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.

Thanks for doing this, I was somewhat dreading it! 😅

One thing I'm not 100% on - are we actually running multi-APIs for Azure Functions apps... I don't think we are, so this basically means we're no longer testing the 1.6.x train...

That's not a reason not to make this PR, and having it in dependabot is still a win. We should just see if we can fix it to run all of them.

As for #6203, I suspect that will become a problem at some point, but it's a pain to fix. It will likely bite us one of these library updates, so we can always punt till then I think...

@bouwkast
Copy link
Contributor Author

One thing I'm not 100% on - are we actually running multi-APIs for Azure Functions apps... I don't think we are, so this basically means we're no longer testing the 1.6.x train...

@andrewlock So would it be easier/quicker to just have two samples for this? One for V1 and one for V2?

@andrewlock
Copy link
Member

One thing I'm not 100% on - are we actually running multi-APIs for Azure Functions apps... I don't think we are, so this basically means we're no longer testing the 1.6.x train...

@andrewlock So would it be easier/quicker to just have two samples for this? One for V1 and one for V2?

I don't think splitting them provides much value. That wouldn't fix the fact that we want to test with the "latest" version of the package - we'd still need to remember to "manually" update to the latest.

But that's essentially a separate requirement - I don't think it should block what you've done here, we will "just" need to update the build to make sure we use multi-build for this sample too, but that can/should be a separate PR IMO.

@bouwkast bouwkast force-pushed the steven/azure-worker-v2 branch from a5f2a66 to eb7b489 Compare December 23, 2024 17:27
@bouwkast bouwkast force-pushed the steven/azure-worker-v2 branch from eb7b489 to ce887d9 Compare January 3, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logs and Traces Missing in Datadog After Upgrading to Azure Functions Worker v2.0.0
2 participants