Skip to content

Conversation

@anna-git
Copy link
Contributor

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

Context

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

  1. #7548 - Add GitLab step and JSON configuration file
  2. #7688 - Cleanup configuration / platform keys + source generator
  3. #7698 - Aliases handling via source generator
  4. #7689 - Analyzers for platform and ConfigurationBuilder
  5. #7697 - Replace manual ConfigurationKeys by generated ones in the whole solution (this PR)

Summary of changes

Fixed the ConfigurationKeysGenerator to properly read and apply the configuration_keys_mapping.json file, and extracted common file header comments to a reusable constant.

Key changes:

  • Fixed JSON array extraction in ParseMappingFile method - the generator was incorrectly trying to extract the "mappings" field as an object instead of an array
  • Extracted configuration generator comments to Constants.ConfigurationGeneratorComment for reuse across multiple generators
  • Updated both ConfigurationKeysGenerator and ConfigKeyAliasesSwitcherGenerator to use the shared constant
  • Added documentation as to how to add a key now

Reason for change

The configuration_keys_mapping.json file was being ignored during code generation, causing the generator to produce incorrect constant names. This meant that any manual edits to constant names in the mapping file were not being respected, and the generated code would use auto-generated names instead of the explicitly mapped ones.

Additionally, the file header comments explaining that files are auto-generated were duplicated across generators, violating DRY principles.

Implementation details

  1. Fixed array extraction logic: Replaced the call to JsonReader.ExtractJsonObjectSection() with custom array extraction code that:

    • Finds the "mappings": key in the JSON
    • Locates the opening [ bracket
    • Tracks bracket nesting to find the matching closing ]
    • Extracts the complete array content
  2. Resolved variable scope issue: Reused existing inString and escapeNext variables from the outer scope instead of redeclaring them, fixing compilation errors.

  3. Centralized header comments: Created Constants.ConfigurationGeneratorComment containing the standardized auto-generation notice and updated both generators to use it.

Test coverage

  • Verified the generator builds successfully without errors
  • The mapping file is now properly parsed and applied during code generation
  • Generated constant names now match the mappings defined in configuration_keys_mapping.json

Other details

This fix ensures that the explicit naming conventions defined in configuration_keys_mapping.json are respected, maintaining consistency with the existing codebase and preventing future confusion when constant names don't match their expected values.

@anna-git anna-git changed the title [Config Registry] Anna/config inversion use generate config keys 5 [Config Registry] Replace manual ConfigurationKeys by generated ones in the whole solution Oct 22, 2025
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from a74a26f to 864cbb6 Compare October 22, 2025 15:45
@pr-commenter
Copy link

pr-commenter bot commented Oct 22, 2025

Benchmarks

Benchmarks Report for benchmark platform 🐌

Benchmarks for #7697 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.164
  • 1 benchmarks are slower, with geometric mean 2.511
  • 5 benchmarks have fewer allocations
  • 2 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 ✔️ Same allocations ✔️

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
#7697 StartStopWithChild net6.0 10.4μs 57.2ns 334ns 0 0 0 5.52 KB
#7697 StartStopWithChild netcoreapp3.1 13.9μs 69.6ns 326ns 0 0 0 5.71 KB
#7697 StartStopWithChild net472 22μs 124ns 896ns 0.966 0.43 0.107 6.01 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
#7697 WriteAndFlushEnrichedTraces net6.0 942μs 76.3ns 285ns 0 0 0 2.7 KB
#7697 WriteAndFlushEnrichedTraces netcoreapp3.1 1.04ms 223ns 834ns 0 0 0 2.7 KB
#7697 WriteAndFlushEnrichedTraces net472 1.22ms 789ns 3.06μ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
#7697 AllCycleSimpleBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
#7697 AllCycleSimpleBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
#7697 AllCycleSimpleBody net472 N/A N/A N/A NaN NaN NaN 0 b
#7697 AllCycleMoreComplexBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
#7697 AllCycleMoreComplexBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
#7697 AllCycleMoreComplexBody net472 N/A N/A N/A NaN NaN NaN 0 b
#7697 ObjectExtractorSimpleBody net6.0 325ns 0.19ns 0.686ns 0 0 0 280 B
#7697 ObjectExtractorSimpleBody netcoreapp3.1 398ns 2.27ns 15ns 0 0 0 272 B
#7697 ObjectExtractorSimpleBody net472 300ns 0.0863ns 0.323ns 0.0433 0 0 281 B
#7697 ObjectExtractorMoreComplexBody net6.0 6.29μs 33.2ns 141ns 0 0 0 3.78 KB
#7697 ObjectExtractorMoreComplexBody netcoreapp3.1 7.91μs 26.4ns 102ns 0 0 0 3.69 KB
#7697 ObjectExtractorMoreComplexBody net472 6.67μs 0.869ns 3.25ns 0.603 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
#7697 EncodeArgs net6.0 76.9μs 108ns 405ns 0 0 0 32.4 KB
#7697 EncodeArgs netcoreapp3.1 95.8μs 316ns 1.22μs 0 0 0 32.4 KB
#7697 EncodeArgs net472 109μs 31.4ns 122ns 4.92 0 0 32.5 KB
#7697 EncodeLegacyArgs net6.0 145μs 23.2ns 89.8ns 0 0 0 2.15 KB
#7697 EncodeLegacyArgs netcoreapp3.1 197μs 47.1ns 170ns 0 0 0 2.15 KB
#7697 EncodeLegacyArgs net472 265μs 102ns 396ns 0 0 0 2.16 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #7697

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑netcoreapp3.1 2.511 295,482.55 742,068.00

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
#7697 RunWafRealisticBenchmark net6.0 395μs 59.1ns 221ns 0 0 0 4.55 KB
#7697 RunWafRealisticBenchmark netcoreapp3.1 417μs 109ns 379ns 0 0 0 4.48 KB
#7697 RunWafRealisticBenchmark net472 427μs 40.8ns 153ns 0 0 0 4.68 KB
#7697 RunWafRealisticBenchmarkWithAttack net6.0 285μs 74ns 277ns 0 0 0 2.24 KB
#7697 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 705μs 10.8μs 105μs 0 0 0 2.22 KB
#7697 RunWafRealisticBenchmarkWithAttack net472 310μs 48.9ns 183ns 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
#7697 SendRequest net6.0 61.7μs 132ns 512ns 0 0 0 14.52 KB
#7697 SendRequest netcoreapp3.1 71.3μs 80.9ns 303ns 0 0 0 17.42 KB
#7697 SendRequest net472 0.000952ns 0.000674ns 0.00261ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7697

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

Fewer allocations 🎉 in #7697

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net6.0 5 B 3 B -2 B -40.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑netcoreapp3.1 1 B 0 b -1 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
#7697 OriginalCharSlice net6.0 1.88ms 4.14μs 16μs 0 0 0 640.01 KB
#7697 OriginalCharSlice netcoreapp3.1 2.13ms 2.83μs 11μs 0 0 0 640 KB
#7697 OriginalCharSlice net472 2.68ms 138ns 517ns 100 0 0 641.95 KB
#7697 OptimizedCharSlice net6.0 1.35ms 449ns 1.74μs 0 0 0 4 B
#7697 OptimizedCharSlice netcoreapp3.1 1.78ms 452ns 1.75μs 0 0 0 1 B
#7697 OptimizedCharSlice net472 2.04ms 419ns 1.62μs 0 0 0 73 B
#7697 OptimizedCharSliceWithPool net6.0 877μs 53.1ns 206ns 0 0 0 3 B
#7697 OptimizedCharSliceWithPool netcoreapp3.1 808μs 31ns 112ns 0 0 0 0 b
#7697 OptimizedCharSliceWithPool net472 1.14ms 174ns 673ns 0 0 0 47 B
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #7697

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

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
#7697 WriteAndFlushEnrichedTraces net6.0 719μs 3.64μs 20.6μs 0 0 0 41.66 KB
#7697 WriteAndFlushEnrichedTraces netcoreapp3.1 727μs 3.87μs 19.4μs 0 0 0 41.84 KB
#7697 WriteAndFlushEnrichedTraces net472 919μs 3.45μs 13.4μs 4.46 0 0 55.92 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
#7697 ExecuteNonQuery net6.0 1.95μs 1.97ns 7.61ns 0 0 0 1.02 KB
#7697 ExecuteNonQuery netcoreapp3.1 2.58μs 8.09ns 31.3ns 0 0 0 1.02 KB
#7697 ExecuteNonQuery net472 2.93μs 3.96ns 15.3ns 0.145 0.0145 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
#7697 CallElasticsearch net6.0 1.71μs 8.52ns 37.2ns 0 0 0 1.03 KB
#7697 CallElasticsearch netcoreapp3.1 2.21μs 11.6ns 54.3ns 0 0 0 1.03 KB
#7697 CallElasticsearch net472 3.44μs 1.05ns 3.92ns 0.155 0 0 1.04 KB
#7697 CallElasticsearchAsync net6.0 1.87μs 5.55ns 20.8ns 0 0 0 1.01 KB
#7697 CallElasticsearchAsync netcoreapp3.1 2.49μs 6.12ns 23.7ns 0 0 0 1.08 KB
#7697 CallElasticsearchAsync net472 3.63μs 2.07ns 7.47ns 0.163 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
#7697 ExecuteAsync net6.0 1.84μs 1.9ns 7.38ns 0 0 0 952 B
#7697 ExecuteAsync netcoreapp3.1 2.51μs 8.85ns 31.9ns 0 0 0 952 B
#7697 ExecuteAsync net472 2.75μs 3.53ns 13.2ns 0.138 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
#7697 SendAsync net6.0 7.11μs 18.7ns 72.5ns 0 0 0 2.36 KB
#7697 SendAsync netcoreapp3.1 8.64μs 7.9ns 29.6ns 0 0 0 2.9 KB
#7697 SendAsync net472 12.2μs 9.99ns 38.7ns 0.488 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7697

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 43.87 KB 45.32 KB 1.45 KB 3.30%

Fewer allocations 🎉 in #7697

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑netcoreapp3.1 44.29 KB 43.62 KB -672 B -1.52%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 274.11 KB 258.18 KB -15.94 KB -5.81%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 275.18 KB 257.6 KB -17.58 KB -6.39%

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
#7697 StringConcatBenchmark net6.0 41.8μs 211ns 1.01μs 0 0 0 45.32 KB
#7697 StringConcatBenchmark netcoreapp3.1 47.2μs 257ns 1.36μs 0 0 0 43.62 KB
#7697 StringConcatBenchmark net472 58μs 145ns 524ns 0 0 0 57.34 KB
#7697 StringConcatAspectBenchmark net6.0 478μs 2.24μs 8.68μs 0 0 0 258.18 KB
#7697 StringConcatAspectBenchmark netcoreapp3.1 498μs 2.55μs 11.4μs 0 0 0 257.6 KB
#7697 StringConcatAspectBenchmark net472 404μs 2.23μs 13.2μs 0 0 0 278.53 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
#7697 EnrichedLog net6.0 2.69μs 13.6ns 59.3ns 0 0 0 1.7 KB
#7697 EnrichedLog netcoreapp3.1 3.56μs 17.7ns 75.1ns 0 0 0 1.7 KB
#7697 EnrichedLog net472 3.8μs 7ns 27.1ns 0.244 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
#7697 EnrichedLog net6.0 123μs 85ns 307ns 0 0 0 4.31 KB
#7697 EnrichedLog netcoreapp3.1 128μs 209ns 753ns 0 0 0 4.31 KB
#7697 EnrichedLog net472 167μs 149ns 576ns 0 0 0 4.52 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
#7697 EnrichedLog net6.0 5.14μs 21.9ns 81.8ns 0 0 0 2.26 KB
#7697 EnrichedLog netcoreapp3.1 6.76μs 24.1ns 90.3ns 0 0 0 2.26 KB
#7697 EnrichedLog net472 7.82μs 6.36ns 24.6ns 0.309 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
#7697 SendReceive net6.0 2.02μs 9.36ns 37.4ns 0 0 0 1.2 KB
#7697 SendReceive netcoreapp3.1 2.58μs 10.4ns 39ns 0 0 0 1.2 KB
#7697 SendReceive net472 3.17μs 3.24ns 12.1ns 0.189 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
#7697 EnrichedLog net6.0 4.37μs 3.31ns 12.4ns 0 0 0 1.58 KB
#7697 EnrichedLog netcoreapp3.1 5.54μs 18.1ns 70.1ns 0 0 0 1.63 KB
#7697 EnrichedLog net472 6.6μs 3.75ns 14.5ns 0.296 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
#7697 StartFinishSpan net6.0 778ns 4.03ns 18.9ns 0 0 0 576 B
#7697 StartFinishSpan netcoreapp3.1 966ns 4.93ns 22.6ns 0 0 0 576 B
#7697 StartFinishSpan net472 947ns 0.259ns 0.968ns 0.0898 0 0 578 B
#7697 StartFinishScope net6.0 926ns 4.79ns 23.5ns 0 0 0 696 B
#7697 StartFinishScope netcoreapp3.1 1.19μs 6.07ns 28.5ns 0 0 0 696 B
#7697 StartFinishScope net472 1.17μs 0.927ns 3.59ns 0.0993 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
#7697 RunOnMethodBegin net6.0 1.1μs 1.88ns 7.29ns 0 0 0 696 B
#7697 RunOnMethodBegin netcoreapp3.1 1.46μs 5.28ns 20.4ns 0 0 0 696 B
#7697 RunOnMethodBegin net472 1.47μs 1.59ns 6.18ns 0.102 0 0 658 B

@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-use-generate-config-keys-5 branch 2 times, most recently from a70301b to caf072d Compare October 22, 2025 17:50
@anna-git anna-git changed the base branch from anna/config-inversion-configuration-analyzers-4 to master October 22, 2025 18:01
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch 2 times, most recently from 52bf0a8 to 38efd42 Compare October 22, 2025 18:27
@anna-git anna-git changed the base branch from master to anna/config-inversion-configuration-analyzers-4 October 22, 2025 18:30
@datadog-official

This comment has been minimized.

@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 83d9c7d to 22a4a69 Compare October 22, 2025 19:40
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 38efd42 to 77c76ec Compare October 22, 2025 19:40
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 22a4a69 to 8c8402b Compare October 22, 2025 20:12
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 77c76ec to 5959568 Compare October 22, 2025 20:12
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 8c8402b to 15b3e9b Compare October 22, 2025 21:02
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 5959568 to 0672899 Compare October 22, 2025 21:02
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 15b3e9b to 071fbd4 Compare October 22, 2025 21:25
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 0672899 to 64b591b Compare October 22, 2025 21:25
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 071fbd4 to 0a751b8 Compare October 22, 2025 21:31
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 64b591b to 4b52ac0 Compare October 22, 2025 21:31
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 0a751b8 to f5dd040 Compare October 22, 2025 22:22
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 4b52ac0 to cf4f9e4 Compare October 22, 2025 22:22
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from f5dd040 to df4a547 Compare October 22, 2025 22:48
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from cf4f9e4 to d5e1ed2 Compare October 22, 2025 22:48
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 704587e to db30e4c Compare October 27, 2025 14:20
@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-use-generate-config-keys-5 branch from db30e4c to 2839ecf Compare October 27, 2025 19:21
@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-use-generate-config-keys-5 branch from 2839ecf to 93a324c Compare October 27, 2025 20:57
@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-use-generate-config-keys-5 branch from 93a324c to 0d30b67 Compare October 28, 2025 14:33
@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 anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 0d30b67 to b95387d 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 🎉


### 1. Add the Configuration Key Definition

Add your new configuration key to `tracer/src/Datadog.Trace/Configuration/supported-configurations.json`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Add your new configuration key to `tracer/src/Datadog.Trace/Configuration/supported-configurations.json`.
Add your new configuration key to `tracer/src/Datadog.Trace/Configuration/supported-configurations.json`, specifying an arbitrary version string (e.g. `"A"`, as shown below). and specifying the product if required.

},
"OTEL_EXPORTER_OTLP_TIMEOUT": {
"version": ["A"],
"product": "OpenTelemetry"
Copy link
Member

Choose a reason for hiding this comment

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

Can we explain:

  1. What the allowed product values are
  2. When you should use them


### 2. Add Documentation

Add XML documentation for your key in `tracer/src/Datadog.Trace/Configuration/supported-configurations-docs.yaml`.
Copy link
Member

Choose a reason for hiding this comment

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

It makes me wonder, why can't we include this in supportedConfigurations to keep everything together? 🤔 Having to edit multiple files to add a new config is a bit annoying


### 5. Build to Generate Code

Build the `Datadog.Trace` project to run the source generator:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Build the `Datadog.Trace` project to run the source generator:
Build the `Datadog.Trace` project to run the source generator, either using Nuke or by building the project directly from the command line or your IDE:


Generates: `ConfigurationKeys.OpenTelemetry.ExporterOtlpEndpoint`

**Common products:**
Copy link
Member

Choose a reason for hiding this comment

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

Ah, in which case we can add a link to this section in step 1 above I think

<Compile Include="..\Datadog.Trace\Configuration\ConfigurationKeys.Exporter.cs" Link="ConfigurationKeys.Exporter.cs" />
<Compile Include="..\Datadog.Trace\Configuration\DeprecationMessages.cs" Link="DeprecationMessages.cs" />
<Compile Include="..\Datadog.Trace\Configuration\ExporterSettings.Shared.cs" Link="ExporterSettings.Shared.cs" />
<!-- Link to generated ConfigurationKeys from Datadog.Trace project -->
Copy link
Member

Choose a reason for hiding this comment

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

Should we just link in all the ConfigurationKeysGenerator files 🤔 After all we included them above?

Copy link
Member

Choose a reason for hiding this comment

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

Nice documentation👍 Could/should we add a link to this document at the top of all the generated ConfigurationKeys files? Rather than mentioning the files to change in those comments, it might make sense to link to this document instead, seeing as that covers everything and means we're not duplicating the explanation? Or just include both 🙂

var enabled = source.GetBool(ConfigurationKeys.FeatureFlags.TraceId128BitGenerationEnabled);
```

## Troubleshooting
Copy link
Member

Choose a reason for hiding this comment

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

Should we mention about the analyzers in this section, and the fact that they enforce not using strings directly etc?

@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-use-generate-config-keys-5 branch from b95387d to e3ec6e4 Compare October 29, 2025 17:15
@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 anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from e3ec6e4 to 98f48d6 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-analyzers-4 branch from 9860a88 to 3197af6 Compare October 30, 2025 18:03
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch 2 times, most recently from 4289adc to efb749a Compare October 30, 2025 19:39
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 3197af6 to e6d6574 Compare October 30, 2025 20:46
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from efb749a to 4a09baa Compare October 30, 2025 20:47
@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-use-generate-config-keys-5 branch from 4a09baa to 6d0d644 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
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 6d0d644 to 0949fba 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