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 mongodb v3 #6354

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

Add support for mongodb v3 #6354

wants to merge 11 commits into from

Conversation

andrewlock
Copy link
Member

@andrewlock andrewlock commented Nov 26, 2024

Summary of changes

Adds support for MongoDb.Driver

Reason for change

We want to support the latest versions of packages

Implementation details

A little more involved than is often the case:

  • Bump the package generation to support testing Mongo 3.x.x
  • Update the integrations to support instrumenting an additional assembly
    • 3.x moved types from the "core" assembly into the "driver" assembly
  • Update the BsonWriter implementation
    • 3.x added two new methods to the IBsonWriter interface
    • That means we have to duplicate the duck typing of both the proxy and our reverse-duck-typed implementation
    • Done in a relatively simple/naive way (check for the presence of the new method to decide if we're in v3 or not) - could improve this later if there are more changes, but it works so meh
  • MongoDB.Driver 3.x changed the default format of JSON serialization, so the serialized mongodb.query tag will change when updating from v2 -> v3 of MongoDB.Driver

Test coverage

Covered by existing tests. Had to do some minor additional scrubbing to handle changes in formatting.

Other details

Fixes #6345

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

@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 Nov 26, 2024
@andrewlock andrewlock requested review from a team as code owners November 26, 2024 13:54
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Nov 26, 2024

Datadog Report

Branch report: andrew/mongodb-3
Commit report: 6f2147a
Test service: dd-trace-dotnet

✅ 0 Failed, 456717 Passed, 3578 Skipped, 32h 26m 32.75s Total Time

@andrewlock
Copy link
Member Author

andrewlock commented Nov 26, 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 (6354) - mean (69ms)  : 66, 72
     .   : milestone, 69,
    master - mean (69ms)  : 65, 74
     .   : milestone, 69,

    section CallTarget+Inlining+NGEN
    This PR (6354) - mean (980ms)  : 958, 1002
     .   : milestone, 980,
    master - mean (976ms)  : 953, 999
     .   : milestone, 976,

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

    section CallTarget+Inlining+NGEN
    This PR (6354) - mean (676ms)  : 663, 689
     .   : milestone, 676,
    master - mean (678ms)  : 659, 697
     .   : milestone, 678,

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

    section CallTarget+Inlining+NGEN
    This PR (6354) - mean (631ms)  : 614, 647
     .   : milestone, 631,
    master - mean (633ms)  : 614, 651
     .   : milestone, 633,

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

    section CallTarget+Inlining+NGEN
    This PR (6354) - mean (1,092ms)  : 1057, 1127
     .   : milestone, 1092,
    master - mean (1,092ms)  : 1068, 1116
     .   : milestone, 1092,

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

    section CallTarget+Inlining+NGEN
    This PR (6354) - mean (870ms)  : 838, 901
     .   : milestone, 870,
    master - mean (870ms)  : 835, 905
     .   : milestone, 870,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6354) - mean (266ms)  : 262, 270
     .   : milestone, 266,
    master - mean (265ms)  : 261, 269
     .   : milestone, 265,

    section CallTarget+Inlining+NGEN
    This PR (6354) - mean (850ms)  : 815, 884
     .   : milestone, 850,
    master - mean (850ms)  : 811, 888
     .   : milestone, 850,

Loading

@lucaspimentel lucaspimentel added type:enhancement Improvement to an existing feature and removed area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) labels Nov 26, 2024
@andrewlock
Copy link
Member Author

andrewlock commented Nov 26, 2024

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 (6354) (11.204M)   : 0, 11204074
    master (10.997M)   : 0, 10996550
    benchmarks/2.9.0 (11.033M)   : 0, 11032866

    section Automatic
    This PR (6354) (7.378M)   : 0, 7378029
    master (7.185M)   : 0, 7184511
    benchmarks/2.9.0 (7.786M)   : 0, 7785853

    section Trace stats
    master (7.538M)   : 0, 7538247

    section Manual
    master (11.069M)   : 0, 11069430

    section Manual + Automatic
    This PR (6354) (6.837M)   : 0, 6836564
    master (6.738M)   : 0, 6737616

    section DD_TRACE_ENABLED=0
    master (10.302M)   : 0, 10301778

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6354) (9.270M)   : 0, 9269830
    master (9.415M)   : 0, 9414535
    benchmarks/2.9.0 (9.495M)   : 0, 9494821

    section Automatic
    This PR (6354) (6.440M)   : 0, 6440336
    master (6.358M)   : 0, 6358468

    section Trace stats
    master (6.815M)   : 0, 6815014

    section Manual
    master (9.493M)   : 0, 9493123

    section Manual + Automatic
    This PR (6354) (5.893M)   : 0, 5893269
    master (5.926M)   : 0, 5926110

    section DD_TRACE_ENABLED=0
    master (8.735M)   : 0, 8735109

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6354) (10.734M)   : 0, 10733619
    master (10.430M)   : 0, 10430317
    benchmarks/2.9.0 (10.020M)   : 0, 10019592

    section Automatic
    This PR (6354) (6.705M)   : 0, 6704986
    master (6.844M)   : 0, 6843537
    benchmarks/2.9.0 (7.255M)   : 0, 7255257

    section Trace stats
    master (7.470M)   : 0, 7470195

    section Manual
    master (10.484M)   : 0, 10483521

    section Manual + Automatic
    This PR (6354) (5.905M)   : crit ,0, 5905321
    master (6.451M)   : 0, 6451333

    section DD_TRACE_ENABLED=0
    master (9.895M)   : 0, 9894875

Loading

@andrewlock
Copy link
Member Author

andrewlock commented Nov 26, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #6354 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.144
  • 1 benchmarks are slower, with geometric mean 1.132
  • 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 ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 8.06μs 44ns 267ns 0.0151 0.00757 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.5μs 57.7ns 336ns 0.0251 0.01 0 5.8 KB
master StartStopWithChild net472 16.2μs 30.6ns 114ns 1.05 0.317 0.106 6.21 KB
#6354 StartStopWithChild net6.0 8.07μs 45.3ns 321ns 0.012 0.00399 0 5.61 KB
#6354 StartStopWithChild netcoreapp3.1 10.3μs 57.3ns 389ns 0.0252 0.0101 0 5.8 KB
#6354 StartStopWithChild net472 16.4μs 31.2ns 117ns 1.04 0.298 0.0967 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 488μs 250ns 934ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 672μs 389ns 1.51μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 842μs 610ns 2.36μs 0.422 0 0 3.3 KB
#6354 WriteAndFlushEnrichedTraces net6.0 499μs 317ns 1.23μs 0 0 0 2.7 KB
#6354 WriteAndFlushEnrichedTraces netcoreapp3.1 653μs 220ns 822ns 0 0 0 2.7 KB
#6354 WriteAndFlushEnrichedTraces net472 850μs 325ns 1.22μs 0.419 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 152μs 940ns 9.26μs 0.143 0 0 14.47 KB
master SendRequest netcoreapp3.1 173μs 1.11μs 11μs 0.16 0 0 17.27 KB
master SendRequest net472 0.000309ns 0.000211ns 0.00079ns 0 0 0 0 b
#6354 SendRequest net6.0 152μs 874ns 6.83μs 0.161 0 0 14.47 KB
#6354 SendRequest netcoreapp3.1 170μs 1.07μs 10.6μs 0.136 0 0 17.27 KB
#6354 SendRequest net472 0.000637ns 0.000366ns 0.00142ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #6354

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 41.81 KB 41.59 KB -221 B -0.53%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 574μs 2.85μs 13.1μs 0.595 0 0 41.72 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 686μs 3.56μs 17.5μs 0.331 0 0 41.81 KB
master WriteAndFlushEnrichedTraces net472 888μs 1.76μs 6.6μs 8.3 2.62 0.437 53.29 KB
#6354 WriteAndFlushEnrichedTraces net6.0 564μs 2.84μs 12.1μs 0.587 0 0 41.61 KB
#6354 WriteAndFlushEnrichedTraces netcoreapp3.1 697μs 3.94μs 28.4μs 0.336 0 0 41.59 KB
#6354 WriteAndFlushEnrichedTraces net472 864μs 4.15μs 16.1μs 8.36 2.64 0.44 53.29 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.22μs 0.725ns 2.81ns 0.0142 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.8μs 1.36ns 5.26ns 0.0136 0 0 1.02 KB
master ExecuteNonQuery net472 2.22μs 2.24ns 8.66ns 0.157 0.00112 0 987 B
#6354 ExecuteNonQuery net6.0 1.23μs 0.807ns 2.91ns 0.0142 0 0 1.02 KB
#6354 ExecuteNonQuery netcoreapp3.1 1.77μs 1.99ns 7.45ns 0.0135 0 0 1.02 KB
#6354 ExecuteNonQuery net472 2.1μs 2.63ns 10.2ns 0.156 0.00105 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.19μs 0.487ns 1.82ns 0.0138 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.57μs 0.703ns 2.72ns 0.0133 0 0 976 B
master CallElasticsearch net472 2.68μs 2.87ns 10.7ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.33μs 3.64ns 14.1ns 0.0136 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.68μs 1.51ns 5.64ns 0.0135 0 0 1.02 KB
master CallElasticsearchAsync net472 2.61μs 1.55ns 5.79ns 0.167 0 0 1.05 KB
#6354 CallElasticsearch net6.0 1.24μs 0.46ns 1.66ns 0.0137 0 0 976 B
#6354 CallElasticsearch netcoreapp3.1 1.52μs 0.793ns 3.07ns 0.013 0 0 976 B
#6354 CallElasticsearch net472 2.54μs 1.83ns 7.09ns 0.157 0 0 995 B
#6354 CallElasticsearchAsync net6.0 1.25μs 0.767ns 2.87ns 0.0131 0 0 952 B
#6354 CallElasticsearchAsync netcoreapp3.1 1.63μs 0.836ns 3.01ns 0.0137 0 0 1.02 KB
#6354 CallElasticsearchAsync net472 2.68μs 2.31ns 8.96ns 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.31μs 1.04ns 3.89ns 0.0137 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.58μs 1.29ns 4.98ns 0.0127 0 0 952 B
master ExecuteAsync net472 1.83μs 0.673ns 2.61ns 0.145 0 0 915 B
#6354 ExecuteAsync net6.0 1.33μs 2.56ns 9.91ns 0.0134 0 0 952 B
#6354 ExecuteAsync netcoreapp3.1 1.64μs 2.69ns 10.4ns 0.0131 0 0 952 B
#6354 ExecuteAsync net472 1.81μs 0.865ns 3.24ns 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.4μs 4.4ns 17ns 0.0308 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.27μs 1.13ns 4.22ns 0.0389 0 0 2.85 KB
master SendAsync net472 7.28μs 5.44ns 21.1ns 0.495 0 0 3.12 KB
#6354 SendAsync net6.0 4.33μs 2.06ns 7.96ns 0.0325 0 0 2.31 KB
#6354 SendAsync netcoreapp3.1 5.32μs 2.29ns 8.88ns 0.0372 0 0 2.85 KB
#6354 SendAsync net472 7.34μs 1.87ns 7.25ns 0.496 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.59μs 0.588ns 2.12ns 0.023 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.22μs 1.65ns 5.95ns 0.0222 0 0 1.64 KB
master EnrichedLog net472 2.78μs 1.07ns 3.86ns 0.249 0 0 1.57 KB
#6354 EnrichedLog net6.0 1.47μs 0.922ns 3.57ns 0.0227 0 0 1.64 KB
#6354 EnrichedLog netcoreapp3.1 2.24μs 1.93ns 7.48ns 0.0221 0 0 1.64 KB
#6354 EnrichedLog net472 2.74μs 1.51ns 5.64ns 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 120μs 130ns 502ns 0.0601 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 124μs 130ns 502ns 0 0 0 4.28 KB
master EnrichedLog net472 152μs 124ns 480ns 0.682 0.227 0 4.46 KB
#6354 EnrichedLog net6.0 120μs 72.3ns 280ns 0.0606 0 0 4.28 KB
#6354 EnrichedLog netcoreapp3.1 122μs 250ns 970ns 0 0 0 4.28 KB
#6354 EnrichedLog net472 150μs 172ns 664ns 0.679 0.226 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.47ns 5.69ns 0.0299 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.32μs 2.24ns 8.37ns 0.0303 0 0 2.2 KB
master EnrichedLog net472 4.86μs 1.52ns 5.7ns 0.319 0 0 2.02 KB
#6354 EnrichedLog net6.0 3μs 0.991ns 3.84ns 0.03 0 0 2.2 KB
#6354 EnrichedLog netcoreapp3.1 4.3μs 1.38ns 4.98ns 0.0301 0 0 2.2 KB
#6354 EnrichedLog net472 4.87μs 0.836ns 3.13ns 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.36μs 1.13ns 4.25ns 0.0164 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.77μs 6.95ns 26.9ns 0.0151 0 0 1.14 KB
master SendReceive net472 2.1μs 2.17ns 8.41ns 0.183 0 0 1.16 KB
#6354 SendReceive net6.0 1.37μs 1.11ns 4.3ns 0.0164 0 0 1.14 KB
#6354 SendReceive netcoreapp3.1 1.69μs 0.838ns 3.25ns 0.0152 0 0 1.14 KB
#6354 SendReceive net472 2.11μs 0.649ns 2.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.61μs 0.811ns 3.14ns 0.0222 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.86μs 1.69ns 6.55ns 0.0212 0 0 1.65 KB
master EnrichedLog net472 4.32μs 3.73ns 14.4ns 0.323 0 0 2.04 KB
#6354 EnrichedLog net6.0 2.79μs 0.961ns 3.72ns 0.0224 0 0 1.6 KB
#6354 EnrichedLog netcoreapp3.1 4.04μs 2.25ns 8.43ns 0.0222 0 0 1.65 KB
#6354 EnrichedLog net472 4.43μs 3.36ns 13ns 0.324 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6354

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 1.132 563.43 637.98

Faster 🎉 in #6354

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.144 467.35 408.39

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 468ns 0.262ns 1.02ns 0.00817 0 0 576 B
master StartFinishSpan netcoreapp3.1 563ns 0.262ns 1.01ns 0.00774 0 0 576 B
master StartFinishSpan net472 679ns 0.519ns 2.01ns 0.0918 0 0 578 B
master StartFinishScope net6.0 491ns 0.297ns 1.15ns 0.00981 0 0 696 B
master StartFinishScope netcoreapp3.1 687ns 1.29ns 4.83ns 0.00958 0 0 696 B
master StartFinishScope net472 863ns 0.561ns 2.17ns 0.104 0 0 658 B
#6354 StartFinishSpan net6.0 408ns 0.245ns 0.95ns 0.00798 0 0 576 B
#6354 StartFinishSpan netcoreapp3.1 638ns 0.601ns 2.33ns 0.00774 0 0 576 B
#6354 StartFinishSpan net472 706ns 0.396ns 1.54ns 0.0915 0 0 578 B
#6354 StartFinishScope net6.0 479ns 0.145ns 0.541ns 0.00966 0 0 696 B
#6354 StartFinishScope netcoreapp3.1 742ns 0.662ns 2.56ns 0.00953 0 0 696 B
#6354 StartFinishScope net472 853ns 0.324ns 1.26ns 0.105 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 598ns 0.442ns 1.65ns 0.00985 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 884ns 0.795ns 3.08ns 0.00929 0 0 696 B
master RunOnMethodBegin net472 1.16μs 4.01ns 14.4ns 0.104 0 0 658 B
#6354 RunOnMethodBegin net6.0 601ns 0.236ns 0.914ns 0.00962 0 0 696 B
#6354 RunOnMethodBegin netcoreapp3.1 906ns 0.48ns 1.86ns 0.00951 0 0 696 B
#6354 RunOnMethodBegin net472 1.15μs 0.416ns 1.56ns 0.104 0 0 658 B

@@ -167,6 +181,9 @@ private BsonHelper(
return null;
}

// in v3+ IBsonWriter has extra methods, so we need to handle that differently
var isV3Bson = ibsonWriterType.GetMethod(nameof(IBsonWriterProxyV3.WriteGuid), [typeof(Guid)]) is not null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if a version check on the assembly might be better, but no strong feelings

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was torn tbh, no strong feelings either 🤷‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed... compared to:

var isV3Bson = ibsonWriterType.Assembly.GetName().Version?.Major >= 3;
Method Mean Error StdDev Gen 0 Allocated
HasMethod 15.68 ns 0.155 ns 0.145 ns - -
VersionCheck 438.11 ns 6.453 ns 6.037 ns 0.0019 584 B

Copy link
Contributor

@bouwkast bouwkast left a comment

Choose a reason for hiding this comment

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

Thanks looks good to me

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) type:enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When will MongoDB.Driver version 3 be supported?
4 participants