DataDog / dd-trace-dotnet

.NET Client Library for Datadog APM
https://docs.datadoghq.com/tracing/
Apache License 2.0
456 stars 142 forks source link

[Tracer] Skip inserting the startup hook into methods in the type `Costura.AssemblyLoader` (#5910 -> v2) #5934

Closed lucaspimentel closed 2 months ago

lucaspimentel commented 2 months ago

Summary of changes

For automatic instrumentation, the tracer inserts a startup hook inside the first method that we deem as a "valid" startup hook callsite. This change adds logic so that methods inside the Costura.AssemblyLoader type are not "valid" startup hook callsites, so that the insertion of the startup hook can be delayed to a later method call.

Reason for change

We've seen a case where a WCF client application uses Costura.Fody, and when instrumentation is added to the application it begins running into assembly loading issues with the following exception:

System.Configuration.ConfigurationErrorsException: Configuration binding extension 'system.serviceModel/bindings/basicHttpsBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly. (C:\scratch\APMS-00000\WcfServiceLibrary1\GettingStartedClient\bin\Debug\GettingStartedClient.exe.Config line 8)

   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) in System.Configuration\BaseConfigurationRecord.cs:line 1379
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) in System.Configuration\BaseConfigurationRecord.cs:line 1314
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) in System.Configuration\BaseConfigurationRecord.cs:line 1157
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) in System.Configuration\BaseConfigurationRecord.cs:line 1157
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) in System.Configuration\BaseConfigurationRecord.cs:line 1157
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) in System.Configuration\BaseConfigurationRecord.cs:line 1000
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) in System.Configuration\BaseConfigurationRecord.cs:line 579
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) in System.Configuration\ClientConfigurationSystem.cs:line 179
   at System.Configuration.ConfigurationManager.GetSection(String sectionName) in System.Configuration\ConfigurationManager.cs:line 171
   at System.ServiceModel.Activation.AspNetEnvironment.UnsafeGetSectionFromConfigurationManager(String sectionPath) in System.ServiceModel.Activation\AspNetEnvironment.cs:line 210
   at System.ServiceModel.Activation.AspNetEnvironment.UnsafeGetConfigurationSection(String sectionPath) in System.ServiceModel.Activation\AspNetEnvironment.cs:line 198
   at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(ContextInformation evalContext, String sectionPath) in System.ServiceModel.Configuration\ConfigurationHelpers.cs:line 141
   at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSection(String sectionPath) in System.ServiceModel.Configuration\ConfigurationHelpers.cs:line 194
   at System.ServiceModel.Configuration.ClientSection.UnsafeGetSection() in System.ServiceModel.Configuration\ClientSection.cs:line 49
   at System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext, String configurationName, ContractDescription contract, EndpointAddress address, Boolean wildcard, Boolean useChannelElementKind, ServiceEndpoint& serviceEndpoint) in System.ServiceModel.Description\ConfigLoader.cs:line 1034
   at System.ServiceModel.Description.ConfigLoader.LookupEndpoint(String configurationName, EndpointAddress address, ContractDescription contract, ContextInformation configurationContext) in System.ServiceModel.Description\ConfigLoader.cs:line 495
   at System.ServiceModel.Description.ConfigLoader.LookupEndpoint(String configurationName, EndpointAddress address, ContractDescription contract) in System.ServiceModel.Description\ConfigLoader.cs:line 488
   at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) in System.ServiceModel\ChannelFactory.cs:line 359
   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) in System.ServiceModel\ChannelFactory.cs:line 653
   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName) in System.ServiceModel\ChannelFactory.cs:line 632
   at System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory() in System.ServiceModel\ConfigurationEndpointTrait.cs:line 78
   at System.ServiceModel.ConfigurationEndpointTrait`1.CreateChannelFactory() in System.ServiceModel\ConfigurationEndpointTrait.cs:line 60
   at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait) in System.ServiceModel\ClientBase.cs:line 1755
   at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef() in System.ServiceModel\ClientBase.cs:line 1749
   at System.ServiceModel.ClientBase`1..ctor() in System.ServiceModel\ClientBase.cs:line 1088
   at GettingStartedClient.ServiceReference1.CalculatorClient..ctor() in C:\scratch\APMS-00000\WcfServiceLibrary1\GettingStartedClient\Connected Services\ServiceReference1\Reference.cs:line 51
   at GettingStartedClient.Program.Main(String[] args) in C:\scratch\APMS-00000\WcfServiceLibrary1\GettingStartedClient\Program.cs:line 21

The issue, it appears, is that the Datadog tracing startup hook is being inserted into either the Costura.AssemblyLoader..cctor() or the Costura.AssemblyLoader.Attach() methods, which Costura adds into the module initializer of the target assembly. These methods add an AssemblyResolve event handler so that the application can load dependent assemblies from the assembly resources, since they are no longer on disk. Since the tracing startup hook also adds an AssemblyResolve event handler, I experimented with delaying the startup hook insertion so that the Costura AssemblyResolve event handler would be added first and it....worked.

Implementation details

Adds more logic to the startup hook logic to check against the Costura.AssemblyLoader type when considering if a callsite is valid for startup hook insertion.

Test coverage

I was able to reproduce the issue by:

Before the changes, the application would crash with the above error. After the changes, the application runs without issue.

If needed, I can check in a smoke test but to avoid repository bloat I figured the step-by-step above would be sufficient.

Other details

Internal ticket: APMS-12728 Backporting #5910 from 3.x to 2.x

datadog-ddstaging[bot] commented 2 months ago

Datadog Report

Branch report: lpimentel/backport-pr5910-jira Commit report: c0ab9ed Test service: dd-trace-dotnet

:white_check_mark: 0 Failed, 352467 Passed, 2263 Skipped, 23h 8m 8.49s Total Time

andrewlock commented 2 months ago

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:

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 (5934) - mean (75ms)  : 63, 87
     .   : milestone, 75,

    section CallTarget+Inlining+NGEN
    This PR (5934) - mean (1,036ms)  : 1001, 1071
     .   : milestone, 1036,
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5934) - mean (111ms)  : 106, 116
     .   : milestone, 111,

    section CallTarget+Inlining+NGEN
    This PR (5934) - mean (721ms)  : 699, 742
     .   : milestone, 721,
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5934) - mean (94ms)  : 90, 98
     .   : milestone, 94,

    section CallTarget+Inlining+NGEN
    This PR (5934) - mean (671ms)  : 652, 691
     .   : milestone, 671,
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5934) - mean (190ms)  : 187, 193
     .   : milestone, 190,

    section CallTarget+Inlining+NGEN
    This PR (5934) - mean (1,115ms)  : 1086, 1143
     .   : milestone, 1115,
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5934) - mean (275ms)  : 271, 279
     .   : milestone, 275,

    section CallTarget+Inlining+NGEN
    This PR (5934) - mean (879ms)  : 856, 903
     .   : milestone, 879,
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5934) - mean (265ms)  : 260, 270
     .   : milestone, 265,

    section CallTarget+Inlining+NGEN
    This PR (5934) - mean (867ms)  : 849, 884
     .   : milestone, 867,
andrewlock commented 2 months ago

Benchmarks Report for tracer :snail:

Benchmarks for #5934 compared to master:

The following thresholds were used for comparing the benchmark speeds:

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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartStopWithChild`|net6.0|7.98μs|45ns|305ns|0.0188| 0.0075|0|5.43 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartStopWithChild`|netcoreapp3.1|9.93μs|56ns|376ns|0.0297| 0.0149|0|5.62 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartStopWithChild`|net472|15.8μs|55.7ns|216ns|1.02| 0.306|0.0943|6.06 KB| |#5934|`StartStopWithChild`|net6.0|7.77μs|43.5ns|272ns|0.015| 0.00748|0|5.42 KB| |#5934|`StartStopWithChild`|netcoreapp3.1|10μs|51.7ns|242ns|0.0199| 0.00996|0|5.62 KB| |#5934|`StartStopWithChild`|net472|16.1μs|55.6ns|215ns|1.01| 0.306|0.0942|6.06 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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`WriteAndFlushEnrichedTraces`|net6.0|459μs|209ns|809ns|0| 0|0|2.7 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`WriteAndFlushEnrichedTraces`|netcoreapp3.1|635μs|426ns|1.59μs|0| 0|0|2.7 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`WriteAndFlushEnrichedTraces`|net472|845μs|532ns|1.99μs|0.422| 0|0|3.3 KB| |#5934|`WriteAndFlushEnrichedTraces`|net6.0|480μs|212ns|793ns|0| 0|0|2.7 KB| |#5934|`WriteAndFlushEnrichedTraces`|netcoreapp3.1|650μs|163ns|632ns|0| 0|0|2.7 KB| |#5934|`WriteAndFlushEnrichedTraces`|net472|842μs|532ns|2.06μs|0.422| 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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendRequest`|net6.0|192μs|1.07μs|7.01μs|0.198| 0|0|18.45 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendRequest`|netcoreapp3.1|214μs|1.22μs|9.35μs|0.211| 0|0|20.61 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendRequest`|net472|0.000893ns|0.000468ns|0.00175ns|0| 0|0|0 b| |#5934|`SendRequest`|net6.0|190μs|949ns|5.53μs|0.181| 0|0|18.45 KB| |#5934|`SendRequest`|netcoreapp3.1|211μs|1.21μs|9.37μs|0.209| 0|0|20.61 KB| |#5934|`SendRequest`|net472|0.00466ns|0.00154ns|0.00597ns|0| 0|0|0 b|
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed :heavy_check_mark: More allocations :warning: #### More allocations :warning: in #5934 | Benchmark | Base Allocated | Diff Allocated | Change | Change % | |:----------|-----------:|-----------:|--------:|--------:| | Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 | 41.42 KB | 41.86 KB | 441 B | 1.06% ### Raw results | Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |---------|---------------------------- |-------------- |---------:|---------:|--------:|-------:|------:|------:|----------:| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`WriteAndFlushEnrichedTraces`|net6.0|573μs|989ns|3.57μs|0.536| 0|0|41.76 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`WriteAndFlushEnrichedTraces`|netcoreapp3.1|731μs|3.79μs|19.3μs|0.368| 0|0|41.42 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`WriteAndFlushEnrichedTraces`|net472|880μs|3.72μs|14.4μs|8.8| 2.64|0.44|53.34 KB| |#5934|`WriteAndFlushEnrichedTraces`|net6.0|565μs|3.05μs|16.4μs|0.561| 0|0|41.61 KB| |#5934|`WriteAndFlushEnrichedTraces`|netcoreapp3.1|680μs|3.26μs|13μs|0.338| 0|0|41.86 KB| |#5934|`WriteAndFlushEnrichedTraces`|net472|886μs|3.93μs|15.2μs|8.3| 2.62|0.437|53.34 KB|
Benchmarks.Trace.DbCommandBenchmark - Faster :tada: Same allocations :heavy_check_mark: #### Faster :tada: in #5934 | Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality | |:----------|-----------:|-----------:|--------:|--------:| | Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery‑net6.0 | 1.207 | 1,393.67 | 1,155.04 | ### Raw results | Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |---------|---------------------------- |-------------- |---------:|---------:|--------:|-------:|------:|------:|----------:| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`ExecuteNonQuery`|net6.0|1.39μs|0.903ns|3.5ns|0.0139| 0|0|1.02 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`ExecuteNonQuery`|netcoreapp3.1|1.74μs|1.3ns|5.03ns|0.014| 0|0|1.02 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`ExecuteNonQuery`|net472|2.07μs|2.93ns|11.4ns|0.156| 0|0|987 B| |#5934|`ExecuteNonQuery`|net6.0|1.16μs|0.906ns|3.51ns|0.0144| 0|0|1.02 KB| |#5934|`ExecuteNonQuery`|netcoreapp3.1|1.67μs|1.14ns|4.26ns|0.0134| 0|0|1.02 KB| |#5934|`ExecuteNonQuery`|net472|2.03μs|2.54ns|9.85ns|0.156| 0|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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`CallElasticsearch`|net6.0|1.22μs|1.52ns|5.7ns|0.0138| 0|0|976 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`CallElasticsearch`|netcoreapp3.1|1.61μs|3.11ns|12.1ns|0.0131| 0|0|976 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`CallElasticsearch`|net472|2.4μs|1.63ns|6.32ns|0.158| 0|0|995 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`CallElasticsearchAsync`|net6.0|1.2μs|0.715ns|2.68ns|0.0132| 0|0|952 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`CallElasticsearchAsync`|netcoreapp3.1|1.61μs|0.613ns|2.3ns|0.0137| 0|0|1.02 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`CallElasticsearchAsync`|net472|2.57μs|1.35ns|5.24ns|0.167| 0|0|1.05 KB| |#5934|`CallElasticsearch`|net6.0|1.11μs|1.46ns|5.66ns|0.0137| 0|0|976 B| |#5934|`CallElasticsearch`|netcoreapp3.1|1.57μs|0.53ns|1.98ns|0.0134| 0|0|976 B| |#5934|`CallElasticsearch`|net472|2.45μs|2.14ns|8.28ns|0.158| 0|0|995 B| |#5934|`CallElasticsearchAsync`|net6.0|1.33μs|1.11ns|4.29ns|0.0133| 0|0|952 B| |#5934|`CallElasticsearchAsync`|netcoreapp3.1|1.59μs|1.65ns|6.19ns|0.0136| 0|0|1.02 KB| |#5934|`CallElasticsearchAsync`|net472|2.62μs|0.862ns|2.99ns|0.166| 0.0013|0|1.05 KB|
Benchmarks.Trace.GraphQLBenchmark - Faster :tada: Same allocations :heavy_check_mark: #### Faster :tada: in #5934 | Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality | |:----------|-----------:|-----------:|--------:|--------:| | Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync‑net6.0 | 1.121 | 1,268.26 | 1,131.01 | ### Raw results | Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |---------|---------------------------- |-------------- |---------:|---------:|--------:|-------:|------:|------:|----------:| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`ExecuteAsync`|net6.0|1.27μs|1.09ns|4.08ns|0.0133| 0|0|952 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`ExecuteAsync`|netcoreapp3.1|1.65μs|0.858ns|3.21ns|0.0125| 0|0|952 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`ExecuteAsync`|net472|1.66μs|0.384ns|1.44ns|0.145| 0|0|915 B| |#5934|`ExecuteAsync`|net6.0|1.13μs|0.341ns|1.28ns|0.0135| 0|0|952 B| |#5934|`ExecuteAsync`|netcoreapp3.1|1.6μs|0.879ns|3.4ns|0.0129| 0|0|952 B| |#5934|`ExecuteAsync`|net472|1.72μs|0.783ns|3.03ns|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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendAsync`|net6.0|4.34μs|2.08ns|7.8ns|0.0304| 0|0|2.22 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendAsync`|netcoreapp3.1|5.08μs|1.51ns|5.64ns|0.0357| 0|0|2.76 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendAsync`|net472|7.85μs|2.83ns|11ns|0.497| 0|0|3.15 KB| |#5934|`SendAsync`|net6.0|4.33μs|1.76ns|6.59ns|0.0304| 0|0|2.22 KB| |#5934|`SendAsync`|netcoreapp3.1|5.18μs|1.51ns|5.64ns|0.0362| 0|0|2.76 KB| |#5934|`SendAsync`|net472|7.71μs|3.45ns|12.9ns|0.497| 0|0|3.15 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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net6.0|1.49μs|0.763ns|2.96ns|0.0232| 0|0|1.64 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|netcoreapp3.1|2.24μs|1.61ns|6.02ns|0.0223| 0|0|1.64 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net472|2.65μs|1.83ns|6.59ns|0.249| 0|0|1.57 KB| |#5934|`EnrichedLog`|net6.0|1.45μs|0.702ns|2.62ns|0.0232| 0|0|1.64 KB| |#5934|`EnrichedLog`|netcoreapp3.1|2.21μs|1.9ns|7.36ns|0.0219| 0|0|1.64 KB| |#5934|`EnrichedLog`|net472|2.61μs|1.48ns|5.75ns|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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net6.0|116μs|200ns|774ns|0.0583| 0|0|4.28 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|netcoreapp3.1|120μs|265ns|1.02μs|0| 0|0|4.28 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net472|151μs|201ns|778ns|0.674| 0.225|0|4.46 KB| |#5934|`EnrichedLog`|net6.0|113μs|144ns|557ns|0.0561| 0|0|4.28 KB| |#5934|`EnrichedLog`|netcoreapp3.1|120μs|292ns|1.13μs|0.0595| 0|0|4.28 KB| |#5934|`EnrichedLog`|net472|149μs|197ns|762ns|0.67| 0.223|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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net6.0|3.01μs|0.751ns|2.91ns|0.0301| 0|0|2.2 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|netcoreapp3.1|4.3μs|1.37ns|5.32ns|0.0301| 0|0|2.2 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net472|4.91μs|1.48ns|5.73ns|0.319| 0|0|2.02 KB| |#5934|`EnrichedLog`|net6.0|2.92μs|0.903ns|3.5ns|0.0306| 0|0|2.2 KB| |#5934|`EnrichedLog`|netcoreapp3.1|4.17μs|1.08ns|4.17ns|0.0295| 0|0|2.2 KB| |#5934|`EnrichedLog`|net472|4.92μs|2.12ns|8.2ns|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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendReceive`|net6.0|1.33μs|0.667ns|2.58ns|0.016| 0|0|1.14 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendReceive`|netcoreapp3.1|1.82μs|1.35ns|5.22ns|0.0154| 0|0|1.14 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`SendReceive`|net472|2.21μs|2.01ns|7.77ns|0.183| 0.00111|0|1.16 KB| |#5934|`SendReceive`|net6.0|1.33μs|0.526ns|1.97ns|0.016| 0|0|1.14 KB| |#5934|`SendReceive`|netcoreapp3.1|1.79μs|2.12ns|8.22ns|0.0152| 0|0|1.14 KB| |#5934|`SendReceive`|net472|2.1μs|1.31ns|4.89ns|0.183| 0.00106|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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net6.0|2.88μs|0.836ns|3.24ns|0.0216| 0|0|1.6 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|netcoreapp3.1|4μs|1.16ns|4.48ns|0.022| 0|0|1.65 KB| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`EnrichedLog`|net472|4.32μs|2.36ns|9.14ns|0.323| 0|0|2.04 KB| |#5934|`EnrichedLog`|net6.0|2.78μs|0.791ns|3.06ns|0.0222| 0|0|1.6 KB| |#5934|`EnrichedLog`|netcoreapp3.1|3.89μs|1.74ns|6.52ns|0.0215| 0|0|1.65 KB| |#5934|`EnrichedLog`|net472|4.31μs|2.93ns|11.3ns|0.323| 0|0|2.04 KB|
Benchmarks.Trace.SpanBenchmark - 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](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartFinishSpan`|net6.0|403ns|0.148ns|0.574ns|0.00813| 0|0|576 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartFinishSpan`|netcoreapp3.1|623ns|0.358ns|1.34ns|0.00779| 0|0|576 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartFinishSpan`|net472|666ns|0.202ns|0.783ns|0.0916| 0|0|578 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartFinishScope`|net6.0|535ns|0.185ns|0.715ns|0.00981| 0|0|696 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartFinishScope`|netcoreapp3.1|737ns|0.29ns|1.12ns|0.00951| 0|0|696 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`StartFinishScope`|net472|795ns|1.02ns|3.94ns|0.104| 0|0|658 B| |#5934|`StartFinishSpan`|net6.0|444ns|0.187ns|0.701ns|0.00797| 0|0|576 B| |#5934|`StartFinishSpan`|netcoreapp3.1|605ns|0.474ns|1.83ns|0.00786| 0|0|576 B| |#5934|`StartFinishSpan`|net472|659ns|0.196ns|0.759ns|0.0917| 0|0|578 B| |#5934|`StartFinishScope`|net6.0|487ns|0.203ns|0.787ns|0.0098| 0|0|696 B| |#5934|`StartFinishScope`|netcoreapp3.1|717ns|0.895ns|3.47ns|0.00934| 0|0|696 B| |#5934|`StartFinishScope`|net472|853ns|0.621ns|2.4ns|0.104| 0|0|658 B|
Benchmarks.Trace.TraceAnnotationsBenchmark - Faster :tada: Same allocations :heavy_check_mark: #### Faster :tada: in #5934 | Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality | |:----------|-----------:|-----------:|--------:|--------:| | Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 | 1.145 | 681.18 | 595.16 | | Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑netcoreapp3.1 | 1.118 | 978.91 | 875.96 | ### Raw results | Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |---------|---------------------------- |-------------- |---------:|---------:|--------:|-------:|------:|------:|----------:| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`RunOnMethodBegin`|net6.0|681ns|0.43ns|1.67ns|0.00963| 0|0|696 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`RunOnMethodBegin`|netcoreapp3.1|979ns|0.281ns|1.09ns|0.00936| 0|0|696 B| |[master](https://github.com/DataDog/dd-trace-dotnet/tree/e0d9add131aa15e77624aaf334f6c31c89892aab)|`RunOnMethodBegin`|net472|1.09μs|0.426ns|1.65ns|0.104| 0|0|658 B| |#5934|`RunOnMethodBegin`|net6.0|595ns|0.339ns|1.31ns|0.00986| 0|0|696 B| |#5934|`RunOnMethodBegin`|netcoreapp3.1|876ns|1.86ns|6.71ns|0.00922| 0|0|696 B| |#5934|`RunOnMethodBegin`|net472|1.06μs|0.249ns|0.966ns|0.104| 0|0|658 B|