dd-trace-dotnet icon indicating copy to clipboard operation
dd-trace-dotnet copied to clipboard

[Config Registry] Refactor configuration api to use config registry keys

Open anna-git opened this issue 2 months ago • 3 comments

Summary of changes

This is part of the config registry project aka config inversion. Introduces a type-safe configuration system using source generators and Roslyn analyzers. Configuration keys are now strongly-typed IConfigKey structs generated from a centralized JSON schema, replacing string-based access throughout the codebase.

Key components:

  • 2 source generators that auto-generate ~290 configuration key structs from supported-configurations.json
  • 2 Roslyn analyzers enforcing compile-time validation
  • Refactored IConfigurationSource API to accept only IConfigKey types
  • Banned direct Environment.GetEnvironmentVariable() usage via analyzer

Reason for change

Config registry project: Enable compile-time validation of configuration keys to catch typos and invalid keys during development rather than at runtime. Centralizes all configuration key definitions in a single JSON schema for easier maintenance and consistency across the tracer.


Implementation details

1. Source Generators

ConfigurationKeyGenerator

  • Reads supported-configurations.json (290 configuration keys)
  • Generates readonly structs implementing IConfigKey interface
  • Example: public readonly struct DD_TRACE_ENABLED : IConfigKey { public string GetKey() => "DD_TRACE_ENABLED"; }

ConfigKeyAliasesSwitcherGenerator

  • Generates efficient switch-based alias resolution for deprecated keys
  • Provides O(1) lookup from old keys to current keys

2. Configuration Source API Changes

All IConfigurationSource methods now use generic IConfigKey constraint:

// New signature
ConfigurationResult<string> GetString<TKey>(TKey key, ...) 
    where TKey : struct, IConfigKey;

Updated implementations:

  • StringConfigurationSource and all subclasses (EnvironmentConfigurationSource, NameValueConfigurationSource, DictionaryConfigurationSource, HandsOffConfigurationSource)
  • JsonConfigurationSource, CompositeConfigurationSource, GlobalConfigurationSource

3. ConfigurationBuilder Enhancements

Added type-safe methods:

  • WithKeys<TKey>(TKey key) - accepts IConfigKey structs
  • WithIntegrationKey(string integrationName) - generates DD_TRACE_{INTEGRATION}_ENABLED keys
  • WithIntegrationAnalyticsKey(string integrationName) - generates analytics keys
  • WithIntegrationAnalyticsSampleRateKey(string integrationName) - generates sample rate keys

4. Roslyn Analyzers

PlatformKeyAnalyzer (DD0009)

  • Enforces that ConfigurationBuilder.WithKeys() only accepts constants from ConfigurationKeys or PlatformKeys classes
  • Rejects hardcoded strings, variables, expressions

BannedApiAnalyzers (RS0030)

  • Bans Environment.GetEnvironmentVariable() and direct EnvironmentConfigurationSource instantiation
  • Exemptions via .editorconfig for vendored code, managed loader, and legitimate low-level uses

5. Configuration Organization

  • ConfigurationKeys - general tracer configuration (generated)
  • PlatformKeys - platform-agnostic keys (generated)
  • PlatformKeys.Aws, PlatformKeys.AzureAppService, PlatformKeys.AzureFunctions, PlatformKeys.GCPFunction - platform-specific nested classes
  • supported-configurations.json - single source of truth for all 290 configuration keys

Test coverage

New tests:

  • ConfigurationKeyGeneratorTests.cs - validates source generator with valid/invalid JSON, tests struct generation
  • PlatformKeyAnalyzerTests.cs - validates analyzer detection of hardcoded strings, variables, and approved constants

Updated tests:

  • All configuration-related tests updated to use IConfigKey structs: ConfigurationBuilderTests, CompositeConfigurationSourceTests, GlobalConfigurationSourceTests, IntegrationSettingsTests, TracerSettingsTests, ImmutableAzureAppServiceSettingsTests, ImmutableGCPFunctionSettingsTests, and 10+ others

Results:

  • ✅ 227 configuration tests passing
  • ✅ All analyzer tests passing
  • ✅ Build succeeds across all target frameworks (net461, netstandard2.0, netcoreapp3.1, net6.0)

Other details

Migration example:

// Before
var value = source.GetString("DD_TRACE_ENABLED", telemetry, validator, recordValue);

// After
var value = source.GetString(new ConfigurationKeys.DD_TRACE_ENABLED(), telemetry, validator, recordValue);

Compatibility:

  • Internal API change: IConfigurationSource methods require IConfigKey
  • Public APIs unchanged: Manual instrumentation APIs remain string-based for backward compatibility
  • Deprecated keys continue working through generated alias resolution

Performance:

  • Zero runtime overhead (compile-time validation)
  • O(1) alias lookup via generated switch expressions
  • No heap allocations (struct-based design)

Stats:

  • 90 files changed: +15,384 / -952 lines (mostly generated code)

anna-git avatar Oct 13 '25 23:10 anna-git

⚠️ Tests

⚠️ Warnings

🧪 2 Tests failed

SubmitsOtlpMetrics from Datadog.Trace.ClrProfiler.IntegrationTests.OpenTelemetrySdkTests (Datadog)
Expected metricsData not to be empty.
CallTarget+Inlining+NGEN from Samples.FakeDbCommand.windows.net48.json.scenarios (Datadog)
Overhead threshold exceeded: 1,500.04% (current: 1088.3524ms, baseline: 68.0204ms)

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ed80402 | Docs | Was this helpful? Give us feedback!

datadog-official[bot] avatar Oct 14 '25 00:10 datadog-official[bot]

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:

  • 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.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (72ms)  : 70, 73
     .   : milestone, 72,
    master - mean (72ms)  : 70, 73
     .   : milestone, 72,

    section Baseline
    This PR (7649) - mean (68ms)  : 67, 69
     .   : milestone, 68,
    master - mean (68ms)  : 66, 69
     .   : milestone, 68,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (1,088ms)  : 1023, 1153
     .   : milestone, 1088,
    master - mean (1,048ms)  : 998, 1099
     .   : milestone, 1048,

gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (106ms)  : 105, 107
     .   : milestone, 106,
    master - mean (107ms)  : 105, 108
     .   : milestone, 107,

    section Baseline
    This PR (7649) - mean (106ms)  : 103, 108
     .   : milestone, 106,
    master - mean (106ms)  : 104, 108
     .   : milestone, 106,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (765ms)  : 737, 792
     .   : milestone, 765,
    master - mean (746ms)  : 724, 768
     .   : milestone, 746,

gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (94ms)  : 93, 95
     .   : milestone, 94,
    master - mean (94ms)  : 93, 95
     .   : milestone, 94,

    section Baseline
    This PR (7649) - mean (93ms)  : 91, 95
     .   : milestone, 93,
    master - mean (94ms)  : 92, 96
     .   : milestone, 94,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (712ms)  : 691, 732
     .   : milestone, 712,
    master - mean (706ms)  : 676, 735
     .   : milestone, 706,

gantt
    title Execution time (ms) FakeDbCommand (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (93ms)  : 91, 94
     .   : milestone, 93,
    master - mean (92ms)  : 91, 94
     .   : milestone, 92,

    section Baseline
    This PR (7649) - mean (92ms)  : 90, 94
     .   : milestone, 92,
    master - mean (92ms)  : 90, 94
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (672ms)  : 659, 686
     .   : milestone, 672,
    master - mean (661ms)  : 647, 676
     .   : milestone, 661,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (199ms)  : 192, 205
     .   : milestone, 199,
    master - mean (196ms)  : 192, 199
     .   : milestone, 196,

    section Baseline
    This PR (7649) - mean (195ms)  : 188, 201
     .   : milestone, 195,
    master - mean (192ms)  : 189, 196
     .   : milestone, 192,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (1,221ms)  : 1148, 1295
     .   : milestone, 1221,
    master - mean (1,176ms)  : 1098, 1255
     .   : milestone, 1176,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (278ms)  : 273, 282
     .   : milestone, 278,
    master - mean (276ms)  : 273, 280
     .   : milestone, 276,

    section Baseline
    This PR (7649) - mean (277ms)  : 272, 281
     .   : milestone, 277,
    master - mean (276ms)  : 272, 280
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (968ms)  : 913, 1023
     .   : milestone, 968,
    master - mean (947ms)  : 902, 991
     .   : milestone, 947,

gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (270ms)  : 265, 275
     .   : milestone, 270,
    master - mean (269ms)  : 265, 273
     .   : milestone, 269,

    section Baseline
    This PR (7649) - mean (270ms)  : 263, 278
     .   : milestone, 270,
    master - mean (269ms)  : 265, 273
     .   : milestone, 269,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (944ms)  : 888, 1000
     .   : milestone, 944,
    master - mean (926ms)  : 882, 971
     .   : milestone, 926,

gantt
    title Execution time (ms) HttpMessageHandler (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7649) - mean (271ms)  : 264, 277
     .   : milestone, 271,
    master - mean (270ms)  : 266, 274
     .   : milestone, 270,

    section Baseline
    This PR (7649) - mean (270ms)  : 264, 276
     .   : milestone, 270,
    master - mean (268ms)  : 263, 273
     .   : milestone, 268,

    section CallTarget+Inlining+NGEN
    This PR (7649) - mean (867ms)  : 846, 889
     .   : milestone, 867,
    master - mean (858ms)  : 839, 877
     .   : milestone, 858,

Benchmarks

Benchmarks Report for benchmark platform :snail:

Benchmarks for #7649 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.142
  • 7 benchmarks are slower, with geometric mean 1.450
  • 7 benchmarks have fewer allocations
  • 12 benchmarks have more 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 :heavy_check_mark: More allocations :warning:

More allocations :warning: in #7649

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑netcoreapp3.1 5.71 KB 5.74 KB 29 B 0.51%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 10.5μs 58.5ns 346ns 0 0 0 5.52 KB
master StartStopWithChild netcoreapp3.1 13.7μs 43.8ns 170ns 0 0 0 5.71 KB
master StartStopWithChild net472 21.5μs 121ns 785ns 0.867 0.217 0 6.03 KB
#7649 StartStopWithChild net6.0 10.9μs 60.9ns 385ns 0 0 0 5.52 KB
#7649 StartStopWithChild netcoreapp3.1 14.6μs 67.4ns 270ns 0 0 0 5.74 KB
#7649 StartStopWithChild net472 22μs 100ns 361ns 1.03 0.413 0.103 6 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 WriteAndFlushEnrichedTraces net6.0 937μs 202ns 757ns 0 0 0 2.71 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 1.04ms 267ns 1.03μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 1.18ms 374ns 1.45μs 0 0 0 3.31 KB
#7649 WriteAndFlushEnrichedTraces net6.0 915μs 117ns 421ns 0 0 0 2.71 KB
#7649 WriteAndFlushEnrichedTraces netcoreapp3.1 1.04ms 95.2ns 356ns 0 0 0 2.7 KB
#7649 WriteAndFlushEnrichedTraces net472 1.2ms 61.2ns 221ns 0 0 0 3.31 KB
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Slower :warning: More allocations :warning:

Slower :warning: in #7649

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑net6.0 1.381 366,572.70 506,141.76
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑net6.0 1.368 360,845.54 493,590.38 several?
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑net472 1.340 472,633.80 633,523.91
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑net472 1.338 480,160.88 642,599.38
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑netcoreapp3.1 1.303 517,777.85 674,911.40
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑netcoreapp3.1 1.244 530,596.68 660,280.10

More allocations :warning: in #7649

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑net6.0 180.01 KB 358.92 KB 178.91 KB 99.39%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑net6.0 183.53 KB 362.45 KB 178.91 KB 97.48%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑netcoreapp3.1 185.8 KB 364.71 KB 178.91 KB 96.29%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑netcoreapp3.1 189.23 KB 368.14 KB 178.91 KB 94.55%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑net472 206.3 KB 386.82 KB 180.52 KB 87.50%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑net472 209.85 KB 390.36 KB 180.51 KB 86.02%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 361μs 1.08μs 4.19μs 0 0 0 180.01 KB
master AllCycleSimpleBody netcoreapp3.1 534μs 2.27μs 11.1μs 0 0 0 185.8 KB
master AllCycleSimpleBody net472 472μs 132ns 495ns 32.4 0 0 206.3 KB
master AllCycleMoreComplexBody net6.0 365μs 1.53μs 5.72μs 0 0 0 183.53 KB
master AllCycleMoreComplexBody netcoreapp3.1 520μs 1.81μs 7.03μs 0 0 0 189.23 KB
master AllCycleMoreComplexBody net472 480μs 144ns 557ns 32.4 0 0 209.85 KB
master ObjectExtractorSimpleBody net6.0 317ns 1.51ns 5.85ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 397ns 2.2ns 12.6ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 296ns 0.0214ns 0.077ns 0.0432 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.26μs 33.5ns 171ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.84μs 38.1ns 152ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.59μs 1.19ns 4.44ns 0.596 0 0 3.8 KB
#7649 AllCycleSimpleBody net6.0 485μs 2.7μs 16.6μs 0 0 0 358.92 KB
#7649 AllCycleSimpleBody netcoreapp3.1 655μs 3.18μs 13.5μs 0 0 0 364.71 KB
#7649 AllCycleSimpleBody net472 633μs 134ns 481ns 59.4 3.12 0 386.82 KB
#7649 AllCycleMoreComplexBody net6.0 502μs 2.62μs 12.3μs 0 0 0 362.45 KB
#7649 AllCycleMoreComplexBody netcoreapp3.1 674μs 836ns 3.24μs 0 0 0 368.14 KB
#7649 AllCycleMoreComplexBody net472 642μs 195ns 754ns 59.4 3.12 0 390.36 KB
#7649 ObjectExtractorSimpleBody net6.0 316ns 1.74ns 10.6ns 0 0 0 280 B
#7649 ObjectExtractorSimpleBody netcoreapp3.1 403ns 1.9ns 8.07ns 0 0 0 272 B
#7649 ObjectExtractorSimpleBody net472 308ns 0.559ns 2.16ns 0.0432 0 0 281 B
#7649 ObjectExtractorMoreComplexBody net6.0 6.34μs 33.1ns 159ns 0 0 0 3.78 KB
#7649 ObjectExtractorMoreComplexBody netcoreapp3.1 7.72μs 37ns 161ns 0 0 0 3.69 KB
#7649 ObjectExtractorMoreComplexBody net472 6.69μs 0.819ns 3.17ns 0.601 0 0 3.8 KB
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - 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 EncodeArgs net6.0 76.1μs 318ns 1.23μs 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 96.4μs 35.1ns 136ns 0 0 0 32.4 KB
master EncodeArgs net472 111μs 13.3ns 51.6ns 5 0 0 32.5 KB
master EncodeLegacyArgs net6.0 145μs 47.8ns 179ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 203μs 452ns 1.75μs 0 0 0 2.14 KB
master EncodeLegacyArgs net472 263μs 28.4ns 110ns 0 0 0 2.17 KB
#7649 EncodeArgs net6.0 76.6μs 46.1ns 172ns 0 0 0 32.4 KB
#7649 EncodeArgs netcoreapp3.1 97.1μs 232ns 899ns 0 0 0 32.4 KB
#7649 EncodeArgs net472 108μs 16.4ns 63.7ns 4.88 0 0 32.51 KB
#7649 EncodeLegacyArgs net6.0 148μs 58ns 225ns 0 0 0 2.15 KB
#7649 EncodeLegacyArgs netcoreapp3.1 197μs 122ns 474ns 0 0 0 2.15 KB
#7649 EncodeLegacyArgs net472 264μs 20.9ns 80.9ns 0 0 0 2.17 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Slower :warning: Same allocations :heavy_check_mark:

Slower :warning: in #7649

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑netcoreapp3.1 2.451 296,060.98 725,732.14

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 392μs 43.3ns 162ns 0 0 0 4.55 KB
master RunWafRealisticBenchmark netcoreapp3.1 625μs 237ns 820ns 0 0 0 4.48 KB
master RunWafRealisticBenchmark net472 429μs 55.3ns 207ns 0 0 0 4.66 KB
master RunWafRealisticBenchmarkWithAttack net6.0 286μs 37ns 133ns 0 0 0 2.24 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 296μs 104ns 390ns 0 0 0 2.22 KB
master RunWafRealisticBenchmarkWithAttack net472 311μs 22.1ns 79.8ns 0 0 0 2.29 KB
#7649 RunWafRealisticBenchmark net6.0 404μs 57.4ns 215ns 0 0 0 4.55 KB
#7649 RunWafRealisticBenchmark netcoreapp3.1 595μs 7.73μs 72.1μs 0 0 0 4.48 KB
#7649 RunWafRealisticBenchmark net472 426μs 56.3ns 218ns 0 0 0 4.66 KB
#7649 RunWafRealisticBenchmarkWithAttack net6.0 283μs 56.6ns 212ns 0 0 0 2.24 KB
#7649 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 686μs 11.9μs 119μs 0 0 0 2.22 KB
#7649 RunWafRealisticBenchmarkWithAttack net472 309μs 20.7ns 74.5ns 0 0 0 2.29 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 SendRequest net6.0 61.2μs 35.7ns 134ns 0 0 0 14.52 KB
master SendRequest netcoreapp3.1 71.2μs 236ns 1.18μs 0 0 0 17.42 KB
master SendRequest net472 0.00371ns 0.00131ns 0.00507ns 0 0 0 0 b
#7649 SendRequest net6.0 62.3μs 332ns 1.82μs 0 0 0 14.52 KB
#7649 SendRequest netcoreapp3.1 71.5μs 86.8ns 336ns 0 0 0 17.42 KB
#7649 SendRequest net472 0.031ns 0.0027ns 0.0105ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed :heavy_check_mark: More allocations :warning:

More allocations :warning: in #7649

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑netcoreapp3.1 1 B 2 B 1 B 100.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net6.0 4 B 7 B 3 B 75.00%

Fewer allocations :tada: in #7649

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net6.0 2 B 1 B -1 B -50.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472 73 B 0 b -73 B -100.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑netcoreapp3.1 3 B 0 b -3 B -100.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net472 47 B 0 b -47 B -100.00%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master OriginalCharSlice net6.0 1.85ms 5.78μs 21.6μs 0 0 0 640.01 KB
master OriginalCharSlice netcoreapp3.1 2.16ms 3.59μs 13.4μs 0 0 0 640 KB
master OriginalCharSlice net472 2.67ms 274ns 1.06μs 100 0 0 641.95 KB
master OptimizedCharSlice net6.0 1.39ms 311ns 1.2μs 0 0 0 4 B
master OptimizedCharSlice netcoreapp3.1 1.67ms 626ns 2.42μs 0 0 0 1 B
master OptimizedCharSlice net472 2ms 514ns 1.99μs 0 0 0 73 B
master OptimizedCharSliceWithPool net6.0 863μs 58.8ns 228ns 0 0 0 2 B
master OptimizedCharSliceWithPool netcoreapp3.1 814μs 204ns 789ns 0 0 0 3 B
master OptimizedCharSliceWithPool net472 1.13ms 120ns 450ns 0 0 0 47 B
#7649 OriginalCharSlice net6.0 1.92ms 2.86μs 11.1μs 0 0 0 640.01 KB
#7649 OriginalCharSlice netcoreapp3.1 2.25ms 8.98μs 33.6μs 0 0 0 640 KB
#7649 OriginalCharSlice net472 2.73ms 1.06μs 4.1μs 100 0 0 641.95 KB
#7649 OptimizedCharSlice net6.0 1.47ms 409ns 1.53μs 0 0 0 7 B
#7649 OptimizedCharSlice netcoreapp3.1 1.83ms 629ns 2.44μs 0 0 0 2 B
#7649 OptimizedCharSlice net472 2.18ms 4.51μs 17.5μs 0 0 0 0 b
#7649 OptimizedCharSliceWithPool net6.0 802μs 55.4ns 215ns 0 0 0 1 B
#7649 OptimizedCharSliceWithPool netcoreapp3.1 797μs 93ns 348ns 0 0 0 0 b
#7649 OptimizedCharSliceWithPool net472 1.15ms 131ns 507ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Faster :tada: More allocations :warning:

Faster :tada: in #7649

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 1.142 990,304.46 867,207.08

More allocations :warning: in #7649

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 41.82 KB 42.51 KB 698 B 1.67%
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 56.04 KB 56.53 KB 483 B 0.86%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 696μs 826ns 2.98μs 0 0 0 41.82 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 757μs 4.2μs 25.5μs 0 0 0 42.25 KB
master WriteAndFlushEnrichedTraces net472 985μs 4.74μs 19.5μs 4.46 0 0 56.04 KB
#7649 WriteAndFlushEnrichedTraces net6.0 740μs 2.22μs 7.68μs 0 0 0 42.51 KB
#7649 WriteAndFlushEnrichedTraces netcoreapp3.1 759μs 1.82μs 6.31μs 0 0 0 42.27 KB
#7649 WriteAndFlushEnrichedTraces net472 863μs 4.6μs 23.4μs 8.33 0 0 56.53 KB
Benchmarks.Trace.DbCommandBenchmark - 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 ExecuteNonQuery net6.0 1.93μs 6.01ns 23.3ns 0 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 2.61μs 8.48ns 31.7ns 0 0 0 1.02 KB
master ExecuteNonQuery net472 3.02μs 3.85ns 14.9ns 0.153 0.0153 0 987 B
#7649 ExecuteNonQuery net6.0 1.85μs 5.71ns 21.4ns 0 0 0 1.02 KB
#7649 ExecuteNonQuery netcoreapp3.1 2.52μs 12ns 46.6ns 0 0 0 1.02 KB
#7649 ExecuteNonQuery net472 2.9μs 5.82ns 22.5ns 0.144 0.0144 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 CallElasticsearch net6.0 1.78μs 8.99ns 43.1ns 0 0 0 1.03 KB
master CallElasticsearch netcoreapp3.1 2.29μs 3.87ns 14.5ns 0 0 0 1.03 KB
master CallElasticsearch net472 3.71μs 3.66ns 14.2ns 0.165 0 0 1.04 KB
master CallElasticsearchAsync net6.0 1.86μs 1.23ns 4.27ns 0 0 0 1.01 KB
master CallElasticsearchAsync netcoreapp3.1 2.42μs 12ns 53.7ns 0 0 0 1.08 KB
master CallElasticsearchAsync net472 3.79μs 3.37ns 13ns 0.169 0 0 1.1 KB
#7649 CallElasticsearch net6.0 1.8μs 1.93ns 7.48ns 0 0 0 1.03 KB
#7649 CallElasticsearch netcoreapp3.1 2.33μs 9.49ns 36.8ns 0 0 0 1.03 KB
#7649 CallElasticsearch net472 3.64μs 5.38ns 20.9ns 0.165 0 0 1.04 KB
#7649 CallElasticsearchAsync net6.0 1.89μs 9.18ns 39ns 0 0 0 1.01 KB
#7649 CallElasticsearchAsync netcoreapp3.1 2.47μs 10.9ns 42.3ns 0 0 0 1.08 KB
#7649 CallElasticsearchAsync net472 3.95μs 4ns 14.4ns 0.158 0 0 1.1 KB
Benchmarks.Trace.GraphQLBenchmark - 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 ExecuteAsync net6.0 1.87μs 7.85ns 30.4ns 0 0 0 952 B
master ExecuteAsync netcoreapp3.1 2.37μs 3.58ns 13.9ns 0 0 0 952 B
master ExecuteAsync net472 2.59μs 4.93ns 19.1ns 0.141 0 0 915 B
#7649 ExecuteAsync net6.0 1.8μs 1.26ns 4.89ns 0 0 0 952 B
#7649 ExecuteAsync netcoreapp3.1 2.42μs 7.68ns 29.7ns 0 0 0 952 B
#7649 ExecuteAsync net472 2.72μs 3.25ns 12.6ns 0.136 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 SendAsync net6.0 6.81μs 10.1ns 37.7ns 0 0 0 2.36 KB
master SendAsync netcoreapp3.1 8.55μs 4.67ns 18.1ns 0 0 0 2.9 KB
master SendAsync net472 12.5μs 10.2ns 39.6ns 0.502 0 0 3.18 KB
#7649 SendAsync net6.0 6.91μs 3.56ns 13.8ns 0 0 0 2.36 KB
#7649 SendAsync netcoreapp3.1 8.51μs 41.1ns 159ns 0 0 0 2.9 KB
#7649 SendAsync net472 12.2μs 6.27ns 24.3ns 0.486 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed :heavy_check_mark: More allocations :warning:

More allocations :warning: in #7649

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 43.78 KB 44.05 KB 272 B 0.62%

Fewer allocations :tada: in #7649

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 260.65 KB 255.74 KB -4.9 KB -1.88%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 286.72 KB 278.53 KB -8.19 KB -2.86%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 278.03 KB 260.82 KB -17.21 KB -6.19%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 42.1μs 241ns 1.58μs 0 0 0 43.78 KB
master StringConcatBenchmark netcoreapp3.1 50.8μs 295ns 2.72μs 0 0 0 42.78 KB
master StringConcatBenchmark net472 57.4μs 114ns 411ns 0 0 0 57.34 KB
master StringConcatAspectBenchmark net6.0 489μs 8.53μs 85.3μs 0 0 0 278.03 KB
master StringConcatAspectBenchmark netcoreapp3.1 531μs 1.02μs 3.82μs 0 0 0 260.65 KB
master StringConcatAspectBenchmark net472 403μs 2.11μs 10.4μs 0 0 0 286.72 KB
#7649 StringConcatBenchmark net6.0 42.7μs 235ns 1.39μs 0 0 0 44.05 KB
#7649 StringConcatBenchmark netcoreapp3.1 49.7μs 288ns 2.09μs 0 0 0 42.64 KB
#7649 StringConcatBenchmark net472 56.2μs 300ns 1.59μs 0 0 0 57.34 KB
#7649 StringConcatAspectBenchmark net6.0 463μs 828ns 2.87μs 0 0 0 260.82 KB
#7649 StringConcatAspectBenchmark netcoreapp3.1 496μs 2.25μs 8.42μs 0 0 0 255.74 KB
#7649 StringConcatAspectBenchmark net472 396μs 2.04μs 15.5μs 0 0 0 278.53 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 EnrichedLog net6.0 2.59μs 3.61ns 14ns 0 0 0 1.7 KB
master EnrichedLog netcoreapp3.1 3.74μs 10.7ns 41.6ns 0 0 0 1.7 KB
master EnrichedLog net472 3.77μs 1.43ns 5.52ns 0.245 0 0 1.64 KB
#7649 EnrichedLog net6.0 2.62μs 11.9ns 46.1ns 0 0 0 1.7 KB
#7649 EnrichedLog netcoreapp3.1 3.57μs 12.8ns 49.5ns 0 0 0 1.7 KB
#7649 EnrichedLog net472 3.81μs 3.63ns 14.1ns 0.246 0 0 1.64 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 EnrichedLog net6.0 122μs 103ns 370ns 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 128μs 106ns 383ns 0 0 0 4.31 KB
master EnrichedLog net472 167μs 101ns 390ns 0 0 0 4.52 KB
#7649 EnrichedLog net6.0 123μs 36.7ns 132ns 0 0 0 4.31 KB
#7649 EnrichedLog netcoreapp3.1 127μs 204ns 789ns 0 0 0 4.31 KB
#7649 EnrichedLog net472 167μs 152ns 547ns 0 0 0 4.52 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 EnrichedLog net6.0 4.92μs 4.36ns 16.3ns 0 0 0 2.26 KB
master EnrichedLog netcoreapp3.1 6.72μs 24.1ns 93.3ns 0 0 0 2.26 KB
master EnrichedLog net472 7.55μs 9.82ns 38ns 0.302 0 0 2.08 KB
#7649 EnrichedLog net6.0 4.86μs 19.3ns 74.9ns 0 0 0 2.26 KB
#7649 EnrichedLog netcoreapp3.1 6.84μs 10.9ns 42.3ns 0 0 0 2.26 KB
#7649 EnrichedLog net472 7.35μs 6.27ns 23.4ns 0.297 0 0 2.08 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 SendReceive net6.0 2.01μs 9.89ns 43.1ns 0 0 0 1.2 KB
master SendReceive netcoreapp3.1 2.53μs 12.9ns 64.7ns 0 0 0 1.2 KB
master SendReceive net472 3.3μs 7.07ns 27.4ns 0.18 0 0 1.2 KB
#7649 SendReceive net6.0 1.99μs 0.815ns 3.05ns 0 0 0 1.2 KB
#7649 SendReceive netcoreapp3.1 2.66μs 3.81ns 13.7ns 0 0 0 1.2 KB
#7649 SendReceive net472 3.28μs 3.9ns 15.1ns 0.18 0 0 1.2 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 EnrichedLog net6.0 4.28μs 6.07ns 22.7ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.62μs 5.44ns 21.1ns 0 0 0 1.63 KB
master EnrichedLog net472 6.7μs 6.11ns 23.7ns 0.301 0 0 2.03 KB
#7649 EnrichedLog net6.0 4.25μs 14.4ns 55.9ns 0 0 0 1.58 KB
#7649 EnrichedLog netcoreapp3.1 5.73μs 21.4ns 82.8ns 0 0 0 1.63 KB
#7649 EnrichedLog net472 6.62μs 7.11ns 27.6ns 0.299 0 0 2.03 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 StartFinishSpan net6.0 763ns 0.259ns 1ns 0 0 0 576 B
master StartFinishSpan netcoreapp3.1 954ns 4.55ns 17.6ns 0 0 0 576 B
master StartFinishSpan net472 904ns 0.74ns 2.87ns 0.0913 0 0 578 B
master StartFinishScope net6.0 907ns 4.84ns 24.2ns 0 0 0 696 B
master StartFinishScope netcoreapp3.1 1.18μs 0.895ns 3.35ns 0 0 0 696 B
master StartFinishScope net472 1.16μs 0.948ns 3.55ns 0.0995 0 0 658 B
#7649 StartFinishSpan net6.0 771ns 4.12ns 21.4ns 0 0 0 576 B
#7649 StartFinishSpan netcoreapp3.1 978ns 5.28ns 25.3ns 0 0 0 576 B
#7649 StartFinishSpan net472 942ns 2.02ns 7.83ns 0.0889 0 0 578 B
#7649 StartFinishScope net6.0 917ns 4.77ns 22.4ns 0 0 0 696 B
#7649 StartFinishScope netcoreapp3.1 1.16μs 6.47ns 29.6ns 0 0 0 696 B
#7649 StartFinishScope net472 1.11μs 0.853ns 3.3ns 0.105 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - 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 RunOnMethodBegin net6.0 1.06μs 5.67ns 29.5ns 0 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1.41μs 6.9ns 27.6ns 0 0 0 696 B
master RunOnMethodBegin net472 1.41μs 1.61ns 6.03ns 0.0991 0 0 658 B
#7649 RunOnMethodBegin net6.0 1.06μs 0.857ns 3.32ns 0 0 0 696 B
#7649 RunOnMethodBegin netcoreapp3.1 1.39μs 5.58ns 20.9ns 0 0 0 696 B
#7649 RunOnMethodBegin net472 1.43μs 0.508ns 1.97ns 0.0997 0 0 658 B

pr-commenter[bot] avatar Oct 14 '25 09:10 pr-commenter[bot]