Skip to content

Conversation

@anna-git
Copy link
Contributor

@anna-git anna-git commented Oct 21, 2025

Context

Part of Configuration Inversion (Step 4) - Stack progress:

  1. #7548 - Add GitLab step and JSON configuration file
  2. #7688 - Cleanup configuration / platform keys + analyzers
  3. #7698 - Source generator for ConfigurationKeys
  4. #7689 - Aliases handling and analyzers (this PR)
  5. #7697 - Replace manual ConfigurationKeys with generated version

Summary

Adds source generator for configuration key aliases, integrates alias resolution into ConfigurationBuilder, and adds Roslyn analyzers to enforce proper configuration key usage.

Changes

Alias Source Generator:

  • ConfigKeyAliasesSwitcherGenerator reads aliases from supported-configurations.json
  • Auto-generates switch statements to resolve primary keys from aliases
  • Generated for all target frameworks (net461, netstandard2.0, netcoreapp3.1, net6.0)

ConfigurationBuilder Improvements:

  • Integrated alias resolution directly into ConfigurationBuilder.WithKeys()
  • Removed manual fallback overloads throughout codebase
  • Added GetKeyWithAlias() method to IConfigurationSource interface

IntegrationSettings Special Handling:

  • Updated to use pattern-based key construction (e.g., DD_TRACE_{INTEGRATION}_ENABLED)
  • Simplified configuration reading by leveraging alias system

Roslyn Analyzers:

  • DD0007: PlatformKeysAnalyzer - Enforces use of PlatformKeys for external platform environment variables
  • DD0008: ConfigurationBuilderWithKeysAnalyzer - Enforces use of ConfigurationKeys/PlatformKeys constants in ConfigurationBuilder.WithKeys() calls

Special Cases:

  • Fixed DatadogLoggingFactory to handle deprecated DD_TRACE_LOG_PATH with proper analyzer suppression
  • Updated configuration tests to work with alias resolution

Motivation

Completes configuration inversion by:

  • Auto-generating alias resolution from supported-configurations.json
  • Eliminating manual fallback chains
  • Enforcing compile-time validation of configuration keys
  • Preventing hardcoded strings and typos

Test Coverage

  • Added ConfigKeyAliasesSwitcherGeneratorTests with comprehensive test coverage
  • Added PlatformKeysAnalyzerTests with 146 lines of tests
  • Added ConfigurationBuilderWithKeysAnalyzerTests with 538 lines of tests
  • Updated existing configuration tests for alias support
  • All tests pass with new alias system

Related Work

Builds on #7548 (configuration registry), #7688 (PlatformKeys separation), and #7698 (source generator for ConfigurationKeys).

@anna-git anna-git marked this pull request as ready for review October 21, 2025 16:24
@anna-git anna-git requested review from a team as code owners October 21, 2025 16:24
@anna-git anna-git requested a review from link04 October 21, 2025 16:24
@anna-git anna-git changed the base branch from master to anna/config-inversion-configuration-aliases-switch-3 October 21, 2025 16:25
@anna-git anna-git marked this pull request as draft October 21, 2025 16:25
@anna-git anna-git changed the title anna/config-inversion-configuration-analyzers-4 [Config registry] Analyzers for ConfigurationBuilder, ConfigurationKeys, PlatformKeys Oct 21, 2025
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from be32003 to c983088 Compare October 21, 2025 16:41
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from acaf6cf to c1f7943 Compare October 21, 2025 16:42
@pr-commenter
Copy link

pr-commenter bot commented Oct 21, 2025

Benchmarks

Benchmarks Report for benchmark platform 🐌

Benchmarks for #7689 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.203
  • 1 benchmarks are slower, with geometric mean 2.492
  • 6 benchmarks have fewer allocations
  • 5 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 ✔️ More allocations ⚠️

More allocations ⚠️ in #7689

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net472 6 KB 6.11 KB 106 B 1.77%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 10.7μs 56ns 296ns 0 0 0 5.51 KB
master StartStopWithChild netcoreapp3.1 13.9μs 70.3ns 307ns 0 0 0 5.71 KB
master StartStopWithChild net472 21.8μs 123ns 858ns 0.97 0.323 0.108 6 KB
#7689 StartStopWithChild net6.0 9.91μs 14.1ns 50.8ns 0 0 0 5.5 KB
#7689 StartStopWithChild netcoreapp3.1 13.6μs 66.7ns 283ns 0 0 0 5.71 KB
#7689 StartStopWithChild net472 22.3μs 110ns 454ns 0.939 0.313 0 6.11 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 931μs 337ns 1.22μs 0 0 0 2.71 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 1.03ms 157ns 609ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 1.19ms 38.5ns 144ns 0 0 0 3.31 KB
#7689 WriteAndFlushEnrichedTraces net6.0 927μs 233ns 839ns 0 0 0 2.71 KB
#7689 WriteAndFlushEnrichedTraces netcoreapp3.1 1.05ms 120ns 432ns 0 0 0 2.7 KB
#7689 WriteAndFlushEnrichedTraces net472 1.2ms 294ns 1.1μs 0 0 0 3.31 KB
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Unknown 🤷 Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
master AllCycleSimpleBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
master AllCycleSimpleBody net472 N/A N/A N/A NaN NaN NaN 0 b
master AllCycleMoreComplexBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
master AllCycleMoreComplexBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
master AllCycleMoreComplexBody net472 N/A N/A N/A NaN NaN NaN 0 b
master ObjectExtractorSimpleBody net6.0 315ns 1.78ns 11.4ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 400ns 1.18ns 4.27ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 295ns 0.0423ns 0.147ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.25μs 31.8ns 149ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.77μs 38.7ns 169ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.66μs 2.01ns 7.78ns 0.599 0 0 3.8 KB
#7689 AllCycleSimpleBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
#7689 AllCycleSimpleBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
#7689 AllCycleSimpleBody net472 N/A N/A N/A NaN NaN NaN 0 b
#7689 AllCycleMoreComplexBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
#7689 AllCycleMoreComplexBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
#7689 AllCycleMoreComplexBody net472 N/A N/A N/A NaN NaN NaN 0 b
#7689 ObjectExtractorSimpleBody net6.0 317ns 1.77ns 9.7ns 0 0 0 280 B
#7689 ObjectExtractorSimpleBody netcoreapp3.1 398ns 2.25ns 14.6ns 0 0 0 272 B
#7689 ObjectExtractorSimpleBody net472 300ns 0.0334ns 0.13ns 0.0431 0 0 281 B
#7689 ObjectExtractorMoreComplexBody net6.0 6.22μs 31.8ns 152ns 0 0 0 3.78 KB
#7689 ObjectExtractorMoreComplexBody netcoreapp3.1 7.82μs 36.5ns 151ns 0 0 0 3.69 KB
#7689 ObjectExtractorMoreComplexBody net472 6.75μs 1.13ns 4.4ns 0.573 0 0 3.8 KB
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EncodeArgs net6.0 76.2μs 360ns 1.48μs 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 97μs 289ns 1.12μs 0 0 0 32.4 KB
master EncodeArgs net472 111μs 18.6ns 72ns 5.01 0 0 32.5 KB
master EncodeLegacyArgs net6.0 143μs 14.9ns 53.7ns 0 0 0 2.15 KB
master EncodeLegacyArgs netcoreapp3.1 197μs 245ns 949ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 261μs 25.6ns 96ns 0 0 0 2.16 KB
#7689 EncodeArgs net6.0 76.9μs 189ns 706ns 0 0 0 32.4 KB
#7689 EncodeArgs netcoreapp3.1 97.3μs 202ns 781ns 0 0 0 32.4 KB
#7689 EncodeArgs net472 112μs 15.2ns 57ns 5.04 0 0 32.51 KB
#7689 EncodeLegacyArgs net6.0 143μs 18.9ns 70.8ns 0 0 0 2.15 KB
#7689 EncodeLegacyArgs netcoreapp3.1 199μs 410ns 1.59μs 0 0 0 2.15 KB
#7689 EncodeLegacyArgs net472 266μs 40.4ns 157ns 0 0 0 2.16 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #7689

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑netcoreapp3.1 2.492 295,482.55 736,413.95

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 393μs 72.6ns 272ns 0 0 0 4.55 KB
master RunWafRealisticBenchmark netcoreapp3.1 409μs 421ns 1.52μs 0 0 0 4.48 KB
master RunWafRealisticBenchmark net472 427μs 60.9ns 236ns 0 0 0 4.66 KB
master RunWafRealisticBenchmarkWithAttack net6.0 285μs 52.4ns 196ns 0 0 0 2.24 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 295μs 40.9ns 142ns 0 0 0 2.22 KB
master RunWafRealisticBenchmarkWithAttack net472 310μs 21.7ns 83.9ns 0 0 0 2.29 KB
#7689 RunWafRealisticBenchmark net6.0 390μs 58.7ns 212ns 0 0 0 4.55 KB
#7689 RunWafRealisticBenchmark netcoreapp3.1 410μs 135ns 524ns 0 0 0 4.48 KB
#7689 RunWafRealisticBenchmark net472 431μs 85.1ns 330ns 0 0 0 4.66 KB
#7689 RunWafRealisticBenchmarkWithAttack net6.0 288μs 59ns 213ns 0 0 0 2.24 KB
#7689 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 688μs 10.5μs 105μs 0 0 0 2.22 KB
#7689 RunWafRealisticBenchmarkWithAttack net472 309μs 36.4ns 141ns 0 0 0 2.29 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 62.3μs 292ns 1.13μs 0 0 0 14.52 KB
master SendRequest netcoreapp3.1 71.4μs 171ns 641ns 0 0 0 17.42 KB
master SendRequest net472 0.00228ns 0.000869ns 0.00337ns 0 0 0 0 b
#7689 SendRequest net6.0 60.7μs 45ns 168ns 0 0 0 14.52 KB
#7689 SendRequest netcoreapp3.1 71.8μs 158ns 568ns 0 0 0 17.42 KB
#7689 SendRequest net472 0.00189ns 0.00114ns 0.00442ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7689

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net6.0 2 B 4 B 2 B 100.00%

Fewer allocations 🎉 in #7689

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net6.0 5 B 3 B -2 B -40.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472 73 B 0 b -73 B -100.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑netcoreapp3.1 1 B 0 b -1 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.91ms 391ns 1.46μs 0 0 0 640 KB
master OriginalCharSlice netcoreapp3.1 2.12ms 4.75μs 17.1μs 0 0 0 640 KB
master OriginalCharSlice net472 2.72ms 1.02μs 3.68μs 100 0 0 641.95 KB
master OptimizedCharSlice net6.0 1.34ms 268ns 1.04μs 0 0 0 2 B
master OptimizedCharSlice netcoreapp3.1 1.65ms 687ns 2.66μs 0 0 0 1 B
master OptimizedCharSlice net472 1.99ms 253ns 948ns 0 0 0 73 B
master OptimizedCharSliceWithPool net6.0 886μs 41.6ns 161ns 0 0 0 5 B
master OptimizedCharSliceWithPool netcoreapp3.1 808μs 96.8ns 375ns 0 0 0 1 B
master OptimizedCharSliceWithPool net472 1.14ms 132ns 495ns 0 0 0 47 B
#7689 OriginalCharSlice net6.0 1.99ms 6.74μs 26.1μs 0 0 0 640.01 KB
#7689 OriginalCharSlice netcoreapp3.1 2.08ms 4.69μs 17.5μs 0 0 0 640 KB
#7689 OriginalCharSlice net472 2.69ms 817ns 3.16μs 100 0 0 641.95 KB
#7689 OptimizedCharSlice net6.0 1.34ms 264ns 1.02μs 0 0 0 4 B
#7689 OptimizedCharSlice netcoreapp3.1 1.67ms 343ns 1.33μs 0 0 0 1 B
#7689 OptimizedCharSlice net472 1.91ms 274ns 1.06μs 0 0 0 0 b
#7689 OptimizedCharSliceWithPool net6.0 801μs 49ns 183ns 0 0 0 3 B
#7689 OptimizedCharSliceWithPool netcoreapp3.1 811μs 112ns 432ns 0 0 0 0 b
#7689 OptimizedCharSliceWithPool net472 1.16ms 105ns 405ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Faster 🎉 More allocations ⚠️

Faster 🎉 in #7689

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 1.203 847,574.55 704,560.24 several?

More allocations ⚠️ in #7689

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 41.73 KB 41.94 KB 214 B 0.51%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 658μs 3.19μs 13.2μs 0 0 0 41.75 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 819μs 4.8μs 45.8μs 0 0 0 41.73 KB
master WriteAndFlushEnrichedTraces net472 910μs 1.67μs 6.24μs 8.33 0 0 56.08 KB
#7689 WriteAndFlushEnrichedTraces net6.0 693μs 3.87μs 25.4μs 0 0 0 41.73 KB
#7689 WriteAndFlushEnrichedTraces netcoreapp3.1 694μs 3.68μs 19.4μs 0 0 0 41.94 KB
#7689 WriteAndFlushEnrichedTraces net472 887μs 2.2μs 8.52μs 4.46 0 0 56.16 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.93μs 6.47ns 24.2ns 0 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 2.64μs 12.1ns 46.9ns 0 0 0 1.02 KB
master ExecuteNonQuery net472 2.9μs 3.48ns 13.5ns 0.147 0.0147 0 987 B
#7689 ExecuteNonQuery net6.0 1.87μs 1.21ns 4.67ns 0 0 0 1.02 KB
#7689 ExecuteNonQuery netcoreapp3.1 2.63μs 7.17ns 27.8ns 0 0 0 1.02 KB
#7689 ExecuteNonQuery net472 2.95μs 4.57ns 17.7ns 0.147 0.0147 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.7μs 7.85ns 31.4ns 0 0 0 1.03 KB
master CallElasticsearch netcoreapp3.1 2.23μs 10.7ns 45.6ns 0 0 0 1.03 KB
master CallElasticsearch net472 3.57μs 2.64ns 10.2ns 0.16 0 0 1.04 KB
master CallElasticsearchAsync net6.0 1.85μs 6.47ns 25ns 0 0 0 1.01 KB
master CallElasticsearchAsync netcoreapp3.1 2.34μs 8.1ns 30.3ns 0 0 0 1.08 KB
master CallElasticsearchAsync net472 3.66μs 3.9ns 15.1ns 0.164 0 0 1.1 KB
#7689 CallElasticsearch net6.0 1.73μs 8.09ns 37.1ns 0 0 0 1.03 KB
#7689 CallElasticsearch netcoreapp3.1 2.19μs 10.1ns 40.3ns 0 0 0 1.03 KB
#7689 CallElasticsearch net472 3.43μs 3.07ns 11.5ns 0.154 0 0 1.04 KB
#7689 CallElasticsearchAsync net6.0 1.84μs 3.55ns 13.3ns 0 0 0 1.01 KB
#7689 CallElasticsearchAsync netcoreapp3.1 2.37μs 5.39ns 18.7ns 0 0 0 1.08 KB
#7689 CallElasticsearchAsync net472 3.7μs 4.61ns 17.3ns 0.166 0 0 1.1 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.88μs 7.24ns 28.1ns 0 0 0 952 B
master ExecuteAsync netcoreapp3.1 2.5μs 5.46ns 21.2ns 0 0 0 952 B
master ExecuteAsync net472 2.55μs 2.47ns 9.56ns 0.141 0 0 915 B
#7689 ExecuteAsync net6.0 1.97μs 2.65ns 10.3ns 0 0 0 952 B
#7689 ExecuteAsync netcoreapp3.1 2.46μs 10.9ns 42.3ns 0 0 0 952 B
#7689 ExecuteAsync net472 2.62μs 3.18ns 12.3ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 7.11μs 16.5ns 59.6ns 0 0 0 2.36 KB
master SendAsync netcoreapp3.1 8.87μs 16.5ns 63.8ns 0 0 0 2.9 KB
master SendAsync net472 12.1μs 11.5ns 44.5ns 0.484 0 0 3.18 KB
#7689 SendAsync net6.0 7.05μs 16.4ns 63.7ns 0 0 0 2.36 KB
#7689 SendAsync netcoreapp3.1 8.72μs 18.7ns 70ns 0 0 0 2.9 KB
#7689 SendAsync net472 12.1μs 11.4ns 44.1ns 0.488 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7689

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 43.87 KB 47.8 KB 3.93 KB 8.95%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 274.11 KB 278.09 KB 3.98 KB 1.45%

Fewer allocations 🎉 in #7689

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑netcoreapp3.1 44.29 KB 42.89 KB -1.4 KB -3.16%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 275.18 KB 256.97 KB -18.22 KB -6.62%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 43.1μs 245ns 1.6μs 0 0 0 43.87 KB
master StringConcatBenchmark netcoreapp3.1 49.4μs 277ns 1.81μs 0 0 0 44.29 KB
master StringConcatBenchmark net472 56.3μs 286ns 1.31μs 0 0 0 57.34 KB
master StringConcatAspectBenchmark net6.0 465μs 1.66μs 5.98μs 0 0 0 274.11 KB
master StringConcatAspectBenchmark netcoreapp3.1 519μs 1.18μs 4.07μs 0 0 0 275.18 KB
master StringConcatAspectBenchmark net472 404μs 2.11μs 10.7μs 0 0 0 278.53 KB
#7689 StringConcatBenchmark net6.0 42.4μs 231ns 1.32μs 0 0 0 47.8 KB
#7689 StringConcatBenchmark netcoreapp3.1 46.7μs 205ns 1.14μs 0 0 0 42.89 KB
#7689 StringConcatBenchmark net472 57.5μs 167ns 625ns 0 0 0 57.34 KB
#7689 StringConcatAspectBenchmark net6.0 496μs 2.11μs 7.3μs 0 0 0 278.09 KB
#7689 StringConcatAspectBenchmark netcoreapp3.1 483μs 2.15μs 8.06μs 0 0 0 256.97 KB
#7689 StringConcatAspectBenchmark net472 410μs 2.15μs 10.3μs 0 0 0 277.45 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 2.62μs 1.44ns 5.56ns 0 0 0 1.7 KB
master EnrichedLog netcoreapp3.1 3.73μs 17.9ns 71.7ns 0 0 0 1.7 KB
master EnrichedLog net472 4.05μs 2.47ns 8.89ns 0.244 0 0 1.64 KB
#7689 EnrichedLog net6.0 2.63μs 0.554ns 2ns 0 0 0 1.7 KB
#7689 EnrichedLog netcoreapp3.1 3.68μs 17.5ns 67.9ns 0 0 0 1.7 KB
#7689 EnrichedLog net472 4.09μs 4.14ns 16ns 0.243 0 0 1.64 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 124μs 244ns 844ns 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 129μs 492ns 1.84μs 0 0 0 4.31 KB
master EnrichedLog net472 169μs 86.2ns 322ns 0 0 0 4.52 KB
#7689 EnrichedLog net6.0 123μs 66.4ns 248ns 0 0 0 4.31 KB
#7689 EnrichedLog netcoreapp3.1 129μs 286ns 1.11μs 0 0 0 4.31 KB
#7689 EnrichedLog net472 168μs 172ns 665ns 0 0 0 4.51 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 4.95μs 21.5ns 80.4ns 0 0 0 2.26 KB
master EnrichedLog netcoreapp3.1 6.81μs 18.2ns 70.5ns 0 0 0 2.26 KB
master EnrichedLog net472 7.71μs 7.97ns 29.8ns 0.307 0 0 2.08 KB
#7689 EnrichedLog net6.0 5.04μs 17.7ns 68.4ns 0 0 0 2.26 KB
#7689 EnrichedLog netcoreapp3.1 6.78μs 12.3ns 47.7ns 0 0 0 2.26 KB
#7689 EnrichedLog net472 7.64μs 9.63ns 36ns 0.307 0 0 2.08 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.98μs 9.52ns 36.9ns 0 0 0 1.2 KB
master SendReceive netcoreapp3.1 2.63μs 12.9ns 57.5ns 0 0 0 1.2 KB
master SendReceive net472 3.06μs 4.97ns 17.2ns 0.184 0 0 1.2 KB
#7689 SendReceive net6.0 2.02μs 7.82ns 29.3ns 0 0 0 1.2 KB
#7689 SendReceive netcoreapp3.1 2.66μs 10.1ns 39.1ns 0 0 0 1.2 KB
#7689 SendReceive net472 3.03μs 1.64ns 6.36ns 0.181 0 0 1.2 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 4.31μs 14.2ns 55.1ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.65μs 19.7ns 76.1ns 0 0 0 1.63 KB
master EnrichedLog net472 6.56μs 5.4ns 20.9ns 0.293 0 0 2.03 KB
#7689 EnrichedLog net6.0 4.07μs 11.7ns 40.4ns 0 0 0 1.58 KB
#7689 EnrichedLog netcoreapp3.1 5.79μs 9.9ns 35.7ns 0 0 0 1.63 KB
#7689 EnrichedLog net472 6.41μs 4.57ns 17.7ns 0.321 0 0 2.03 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 771ns 3.79ns 15.1ns 0 0 0 576 B
master StartFinishSpan netcoreapp3.1 965ns 4.65ns 18ns 0 0 0 576 B
master StartFinishSpan net472 923ns 0.55ns 2.06ns 0.088 0 0 578 B
master StartFinishScope net6.0 922ns 3.71ns 14.4ns 0 0 0 696 B
master StartFinishScope netcoreapp3.1 1.19μs 5.59ns 21.6ns 0 0 0 696 B
master StartFinishScope net472 1.12μs 0.833ns 3.23ns 0.101 0 0 658 B
#7689 StartFinishSpan net6.0 848ns 4.19ns 19.2ns 0 0 0 576 B
#7689 StartFinishSpan netcoreapp3.1 1.03μs 4.83ns 19.9ns 0 0 0 576 B
#7689 StartFinishSpan net472 935ns 0.248ns 0.893ns 0.0891 0 0 578 B
#7689 StartFinishScope net6.0 907ns 4.88ns 25.8ns 0 0 0 696 B
#7689 StartFinishScope netcoreapp3.1 1.2μs 5.5ns 21.3ns 0 0 0 696 B
#7689 StartFinishScope net472 1.17μs 0.144ns 0.559ns 0.0995 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 1.07μs 5.06ns 20.3ns 0 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1.4μs 7.1ns 31.8ns 0 0 0 696 B
master RunOnMethodBegin net472 1.44μs 0.906ns 3.51ns 0.101 0 0 658 B
#7689 RunOnMethodBegin net6.0 1.08μs 5.58ns 25.6ns 0 0 0 696 B
#7689 RunOnMethodBegin netcoreapp3.1 1.43μs 7.44ns 34.1ns 0 0 0 696 B
#7689 RunOnMethodBegin net472 1.44μs 0.805ns 3.12ns 0.101 0 0 658 B

@dd-trace-dotnet-ci-bot
Copy link

dd-trace-dotnet-ci-bot bot commented Oct 21, 2025

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.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7689) - mean (72ms)  : 71, 73
     .   : milestone, 72,
    master - mean (79ms)  : 76, 82
     .   : milestone, 79,

    section Baseline
    This PR (7689) - mean (68ms)  : 66, 70
     .   : milestone, 68,
    master - mean (75ms)  : 73, 78
     .   : milestone, 75,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (1,058ms)  : 1019, 1098
     .   : milestone, 1058,
    master - mean (1,104ms)  : 1052, 1155
     .   : milestone, 1104,

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

    section Baseline
    This PR (7689) - mean (105ms)  : 103, 108
     .   : milestone, 105,
    master - mean (116ms)  : 112, 121
     .   : milestone, 116,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (757ms)  : 726, 787
     .   : milestone, 757,
    master - mean (789ms)  : 757, 821
     .   : milestone, 789,

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

    section Baseline
    This PR (7689) - mean (94ms)  : 91, 96
     .   : milestone, 94,
    master - mean (103ms)  : 100, 107
     .   : milestone, 103,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (732ms)  : 671, 794
     .   : milestone, 732,
    master - mean (744ms)  : 718, 770
     .   : milestone, 744,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7689) - mean (93ms)  : 92, 95
     .   : milestone, 93,
    master - mean (105ms)  : 98, 112
     .   : milestone, 105,

    section Baseline
    This PR (7689) - mean (93ms)  : 90, 95
     .   : milestone, 93,
    master - mean (103ms)  : 98, 107
     .   : milestone, 103,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (663ms)  : 644, 682
     .   : milestone, 663,
    master - mean (710ms)  : 693, 727
     .   : milestone, 710,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7689) - mean (195ms)  : 193, 198
     .   : milestone, 195,
    master - mean (196ms)  : 193, 199
     .   : milestone, 196,

    section Baseline
    This PR (7689) - mean (193ms)  : 189, 197
     .   : milestone, 193,
    master - mean (194ms)  : 190, 198
     .   : milestone, 194,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (1,182ms)  : 1115, 1249
     .   : milestone, 1182,
    master - mean (1,161ms)  : 1110, 1212
     .   : milestone, 1161,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7689) - mean (278ms)  : 270, 286
     .   : milestone, 278,
    master - mean (279ms)  : 274, 284
     .   : milestone, 279,

    section Baseline
    This PR (7689) - mean (275ms)  : 272, 279
     .   : milestone, 275,
    master - mean (279ms)  : 273, 285
     .   : milestone, 279,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (952ms)  : 907, 997
     .   : milestone, 952,
    master - mean (956ms)  : 912, 1000
     .   : milestone, 956,

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

    section Baseline
    This PR (7689) - mean (270ms)  : 264, 275
     .   : milestone, 270,
    master - mean (270ms)  : 264, 276
     .   : milestone, 270,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (934ms)  : 887, 980
     .   : milestone, 934,
    master - mean (928ms)  : 882, 973
     .   : milestone, 928,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7689) - mean (268ms)  : 265, 271
     .   : milestone, 268,
    master - mean (271ms)  : 266, 277
     .   : milestone, 271,

    section Baseline
    This PR (7689) - mean (267ms)  : 263, 272
     .   : milestone, 267,
    master - mean (270ms)  : 266, 274
     .   : milestone, 270,

    section CallTarget+Inlining+NGEN
    This PR (7689) - mean (854ms)  : 837, 871
     .   : milestone, 854,
    master - mean (856ms)  : 839, 873
     .   : milestone, 856,

Loading

@anna-git anna-git changed the title [Config registry] Analyzers for ConfigurationBuilder, ConfigurationKeys, PlatformKeys [ConfigRegistry] Analyzers for platform and ConfigurationBuilder Oct 22, 2025
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from c983088 to 9e2a61b Compare October 22, 2025 17:26
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from c1f7943 to 56bd199 Compare October 22, 2025 17:26
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch 2 times, most recently from f242046 to 153e7b3 Compare October 22, 2025 18:14
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 56bd199 to e52fd10 Compare October 22, 2025 18:14
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 153e7b3 to bd34118 Compare October 22, 2025 18:27
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from a31063c to 1d5b555 Compare October 27, 2025 14:20
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 59b8625 to acdece9 Compare October 27, 2025 14:20
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 1d5b555 to 5018466 Compare October 27, 2025 19:21
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from acdece9 to 86d6dbd Compare October 27, 2025 19:21
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 5018466 to 783a308 Compare October 27, 2025 20:56
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 86d6dbd to fc26b53 Compare October 27, 2025 20:56
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 783a308 to aa52b7f Compare October 28, 2025 14:33
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from fc26b53 to cc850d6 Compare October 28, 2025 14:33
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from aa52b7f to 0c28972 Compare October 28, 2025 14:55
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from cc850d6 to 2a09875 Compare October 28, 2025 14:55
anna-git added a commit that referenced this pull request Oct 28, 2025
… yaml for doc (#7548)

## Context

Part of **Configuration Inversion (Step 1)** - Stack progress:
1. **→ [#7548](#7548) -
Add GitLab step and JSON configuration file (this PR)**
2. [#7688](#7688) -
Reorganize keys, split config keys and platform keys
3. [#7698](#7698) -
Generate ConfigurationKeys with source generator
4. [#7689](#7689) -
Aliases handling and analyzers
5. [#7697](#7697) -
Replace manual ConfigurationKeys by generated ones in the whole solution



## Summary

Adds centralized configuration registry (`supported-configurations.json`
+
[supported-configurations-docs.yaml](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/supported-configurations-docs.yaml:0:0-0:0))
containing ~280 configuration keys with automated GitLab CI validation.

## Changes

**Configuration Files:**
- `supported-configurations.json` - Machine-readable registry of all
configuration keys with versions, aliases, and deprecations
-
[supported-configurations-docs.yaml](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/supported-configurations-docs.yaml:0:0-0:0)
- Human-readable documentation for each configuration key

**CI/CD:**
- Added `validate_supported_configurations_local_file` step to
`.gitlab-ci.yml`
- Updated `.gitlab/one-pipeline.locked.yaml` to reference validation
template

**File Structure:**
```json
{
  "supportedConfigurations": { "DD_TRACE_ENABLED": { "version": ["A"] }, ... },
  "aliases": { "DD_AGENT_HOST": ["DD_TRACE_AGENT_HOSTNAME", ...], ... },
  "deprecations": { "DD_TRACE_ANALYTICS_ENABLED": "Deprecated - ...", ... }
}
```

## Motivation

Provides single source of truth for configuration keys to enable:
- Automated documentation validation
- Cross-tracer compatibility checks
- Configuration migration tooling
- Automated doc generation

See: [Configuration Registry Design
Doc](https://docs.google.com/document/d/1VIvOyQPfuQIWBIgNY68A9hzLir0-3eJijTwmpWASO8s/edit?tab=t.0#heading=h.jy2ajbk2b8ba)

## Validation

GitLab CI validates JSON structure, naming conventions, and schema
compliance on every build.

## Commit Details

**`2639cf0` - Initial Configuration Registry**
- Added `supported-configurations.json` with ~280 configuration keys
organized by version (A/B/C)
- Includes `aliases` section mapping primary keys to
deprecated/alternative names
- Includes `deprecations` section with deprecation messages
- Added GitLab CI validation step to ensure file integrity
- Updated one-pipeline lock file to reference validation template

**`70e632e` - Configuration Documentation**
- Added
[supported-configurations-docs.yaml](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/supported-configurations-docs.yaml:0:0-0:0)
with detailed XML documentation for each configuration key
- Provides human-readable descriptions, default values, and usage
examples
- Includes `<seealso>` references to relevant code classes
- Complements the machine-readable JSON with developer-friendly
documentation
- Enables automated generation of configuration documentation from a
single source
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.

Nice work 👍

var aliasSection = additionalText.Collect()
.Select(static (files, ct) =>
{
if (files.Length == 0)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this will ever fire 🤔 Given we filter out non-matching texts, I don't think it will. So we can probably just remove the Collect, remove the diagnostic, and make this Select operate on a single file

#pragma warning disable 618 // ProfilerLogPath is deprecated but still supported
var nativeLogFile = config.WithKeys(ConfigurationKeys.ProfilerLogPath).AsString();
#pragma warning restore 618
// ProfilerLogPath is deprecated but still supported. For now, we bypass the WithKeys analyzer, but later we want to pull deprecations differently as part of centralized file
Copy link
Member

Choose a reason for hiding this comment

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

Later, as in later in this config stack, or as in after that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

later as later in config registry v2 😅

Comment on lines +22 to +39
public HasKeys WithIntegrationKey(string integrationName) => new(
_source,
_telemetry,
string.Format(IntegrationSettings.IntegrationEnabledKey, integrationName.ToUpperInvariant()),
[
string.Format(IntegrationSettings.IntegrationEnabledKey, integrationName),
$"DD_{integrationName}_ENABLED"
]);

public HasKeys WithIntegrationAnalyticsKey(string integrationName) => new(
_source,
_telemetry,
#pragma warning disable 618 // App analytics is deprecated, but still used
string.Format(IntegrationSettings.AnalyticsEnabledKey, integrationName.ToUpperInvariant()),
[
string.Format(IntegrationSettings.AnalyticsEnabledKey, integrationName),
#pragma warning restore 618
$"DD_{integrationName}_ANALYTICS_ENABLED"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this makes sense to me - AFAICT what you have today is correct 🤔

Comment on lines 506 to 510
{
var result = selector(Source, Key, Telemetry, validator, recordValue);
if (result.ShouldFallBack && FallbackKey1 is not null)
{
result = selector(Source, FallbackKey1, Telemetry, validator, recordValue);
}

if (result.ShouldFallBack && FallbackKey2 is not null)
{
result = selector(Source, FallbackKey2, Telemetry, validator, recordValue);
}

if (result.ShouldFallBack && FallbackKey3 is not null)
{
result = selector(Source, FallbackKey3, Telemetry, validator, recordValue);
}

return result;
var source = Source;
var telemetry = Telemetry;
return GetResultWithFallback(key => selector(source, key, telemetry, validator, recordValue));
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: can probably just simplify these calls. There's a typo on key though that definitely needs to be fixed (otherwise you're accessing the constructor parameter)

        private ConfigurationResult<T> GetResult<T>(Func<IConfigurationSource, string, IConfigurationTelemetry, Func<T, bool>?, bool, ConfigurationResult<T>> selector, Func<T, bool>? validator, bool recordValue)
            => GetResultWithFallback(key => selector(Source, Key, Telemetry, validator, recordValue));

public HasKeys WithKeys(string key, string fallbackKey1, string fallbackKey2, string fallbackKey3) => new(_source, _telemetry, key, fallbackKey1, fallbackKey2, fallbackKey3);

internal readonly struct HasKeys
public HasKeys WithIntegrationKey(string integrationName) => new(
Copy link
Member

Choose a reason for hiding this comment

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

Such a pain 😅 Part of me wonders if instead of doing string.Format() here, we should have a source-generated mapping from integrationName => keys, but that's totally separate, and something we can investigate later to see if it improves perf


// Filter out tags with empty keys or empty values, and trim whitespaces
var headerTags = InitializeHeaderTags(config, ConfigurationKeys.HeaderTags, headerTagsNormalizationFixEnabled) ?? ReadOnlyDictionary.Empty;
var headerTags = InitializeHeaderTags(config.WithKeys(ConfigurationKeys.HeaderTags), headerTagsNormalizationFixEnabled) ?? ReadOnlyDictionary.Empty;
Copy link
Member

Choose a reason for hiding this comment

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

Example of at callsite:

Suggested change
var headerTags = InitializeHeaderTags(config.WithKeys(ConfigurationKeys.HeaderTags), headerTagsNormalizationFixEnabled) ?? ReadOnlyDictionary.Empty;
var headerTagsConfig = config.WithKeys(ConfigurationKeys.HeaderTags);
var headerTags = InitializeHeaderTags(in headerTagsConfig, headerTagsNormalizationFixEnabled) ?? ReadOnlyDictionary.Empty;

.AsBool(defaultValue: false);

var httpServerErrorStatusCodesString = config
#pragma warning disable 618 // This config key has been replaced but may still be used
Copy link
Member

Choose a reason for hiding this comment

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

ooh, that's a nice benefit where only the aliases are deprecated

Comment on lines +1376 to +1390
internal bool IsErrorStatusCode(int statusCode, bool serverStatusCode)
=> MutableSettings.IsErrorStatusCode(statusCode, serverStatusCode);

internal bool IsIntegrationEnabled(IntegrationId integration, bool defaultValue = true)
=> MutableSettings.IsIntegrationEnabled(integration, defaultValue);

[Obsolete(DeprecationMessages.AppAnalytics)]
internal double? GetIntegrationAnalyticsSampleRate(IntegrationId integration, bool enabledWithGlobalSetting)
=> MutableSettings.GetIntegrationAnalyticsSampleRate(integration, enabledWithGlobalSetting);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to add these here? 🤔

Comment on lines +29 to +33
return new string[]
{
"DATADOG_TRACE_AGENT_HOSTNAME",
"DD_TRACE_AGENT_HOSTNAME"
};
Copy link
Member

Choose a reason for hiding this comment

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

IMO we should update the source generator to use a switch expression and to use collection expressions so that it looks like this:

public static string[] GetAliases(string mainKey)
    => mainKey switch
    {
        "DD_AGENT_HOST" => [ "DATADOG_TRACE_AGENT_HOSTNAME", "DD_TRACE_AGENT_HOSTNAME" ],
        // the rest
        _ => [],
    };

Comment on lines -38 to +39
data.Add(kvp.Key, kvp.Value?.ToString());
// use FormattableString.Invariant as europeans might have 1.23.ToString()=1,23 which makes tests fail
data.Add(kvp.Key, kvp.Value is null ? null : FormattableString.Invariant($"{kvp.Value}"));
Copy link
Member

Choose a reason for hiding this comment

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

TIL about FormattableString

@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 0c28972 to bea714d Compare October 29, 2025 17:15
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 2a09875 to 279b292 Compare October 29, 2025 17:15
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from bea714d to a6668f3 Compare October 29, 2025 17:48
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 279b292 to 9860a88 Compare October 29, 2025 17:49
anna-git added a commit that referenced this pull request Oct 30, 2025
… keys (#7688)

## Context

Part of **Configuration Inversion (Step 2)** - Stack progress:
1. [#7548](#7548) - Add
GitLab step and JSON configuration file
2. **→ [#7688](#7688) -
[Config registry] Reorganize keys, split config keys and platform
keys(this PR)**
3. [#7698](#7698) -
Generate ConfigurationKeys with source generator
4. [#7689](#7689) -
Aliases handling and analyzers
5. [#7697](#7697) -
Replace manual ConfigurationKeys by generated ones in the whole solution
## Summary

Separates platform-specific environment variables into `PlatformKeys`
class and adds Roslyn analyzers to enforce proper usage of configuration
keys throughout the codebase.

## Changes

**Platform Keys Separation:**
- Created `PlatformKeys` class for external platform environment
variables (AWS, Azure, GCP, Kubernetes, CLR Profiler), those that don't
start with DD_ and come from other platforms.
- Updated all references throughout codebase to use `PlatformKeys` for
platform-specific variables
- Keeps `ConfigurationKeys` focused only on Datadog configuration

**Roslyn Analyzers:**
- **DD0007**: Platform key analyzer - Enforces use of `PlatformKeys` for
external platform environment variables
- **DD0008**: ConfigurationBuilder analyzer - Enforces use of
`ConfigurationKeys` or `PlatformKeys` constants in
`ConfigurationBuilder.WithKeys()` calls
- Prevents hardcoded strings and ensures type safety

**Configuration Mapping:**
- Added `configuration_keys_mapping.json` to map environment variable
names to their `ConfigurationKeys` constant names, so that we avoid
renaming hundreds of variables according to automatically source
generated deducted ones.
- Enables preservation of original constant names during refactoring
- Supports source generator integration

**Code Updates:**
- Updated `TracerSettings`, test files, and profiler code to use
`PlatformKeys`
- Replaced manual `ConfigurationKeys` with generated version from
`supported-configurations.json`
- Added missing `DD_TRACE_LOG_PATH` to configuration registry

## Motivation

Ensures clean separation between Datadog and platform configuration by:
- Preventing accidental mixing of platform and Datadog keys
- Enforcing compile-time validation of configuration key usage
- Making it clear which keys are owned by Datadog vs external platforms
- Catching configuration errors at build time instead of runtime

## Validation

- Roslyn analyzers run on every build
- All existing tests pass with updated key references
- Analyzers report clear diagnostic messages for violations

## Related Work

This PR builds on the configuration registry foundation established in
#7548:
- **Commit `2639cf0`** added `supported-configurations.json` with ~280
keys, aliases, deprecations, and GitLab CI validation
- **Commit `70e632e`** added
[supported-configurations-docs.yaml](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/supported-configurations-docs.yaml:0:0-0:0)
with XML documentation for automated doc generation
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from a6668f3 to d90d571 Compare October 30, 2025 18:03
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch 2 times, most recently from 3197af6 to e6d6574 Compare October 30, 2025 20:47
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 6ccb01e to ed3a6bc Compare October 31, 2025 01:39
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from e6d6574 to dcd2f3c Compare October 31, 2025 01:39
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from dcd2f3c to 196d5e0 Compare October 31, 2025 21:41
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.

4 participants