Skip to content

Conversation

@anna-git
Copy link
Contributor

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

This PR was accidentally merged by auto merge, please see #7931

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)
  6. #7905 - Forbid use of System.Environment methods and adapt everywhere

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 slower, with geometric mean 1.141
  • 1 benchmarks have fewer allocations
  • 3 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 ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #7697

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net472 6 KB 5.93 KB -69 B -1.15%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 11.1μs 59.6ns 332ns 0 0 0 5.5 KB
master StartStopWithChild netcoreapp3.1 13.8μs 71.7ns 344ns 0 0 0 5.72 KB
master StartStopWithChild net472 21.8μs 111ns 497ns 0.903 0.226 0 6 KB
#7697 StartStopWithChild net6.0 10.9μs 57.7ns 305ns 0 0 0 5.51 KB
#7697 StartStopWithChild netcoreapp3.1 13.4μs 71.5ns 372ns 0 0 0 5.71 KB
#7697 StartStopWithChild net472 21.8μs 118ns 711ns 0.874 0.219 0 5.93 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 1.25ms 167ns 625ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 1.39ms 3.22μs 12.5μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 1.72ms 1.71μs 6.63μs 0 0 0 3.26 KB
#7697 WriteAndFlushEnrichedTraces net6.0 1.26ms 141ns 528ns 0 0 0 2.7 KB
#7697 WriteAndFlushEnrichedTraces netcoreapp3.1 1.36ms 106ns 381ns 0 0 0 2.7 KB
#7697 WriteAndFlushEnrichedTraces net472 1.7ms 169ns 608ns 0 0 0 3.26 KB
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 1.09μs 6.25ns 51.5ns 0 0 0 1.22 KB
master AllCycleSimpleBody netcoreapp3.1 1.37μs 7.84ns 58.1ns 0 0 0 1.2 KB
master AllCycleSimpleBody net472 1E+03ns 0.202ns 0.727ns 0.194 0 0 1.23 KB
master AllCycleMoreComplexBody net6.0 7.43μs 5.7ns 22.1ns 0 0 0 4.72 KB
master AllCycleMoreComplexBody netcoreapp3.1 8.97μs 47.2ns 227ns 0 0 0 4.62 KB
master AllCycleMoreComplexBody net472 7.66μs 4.93ns 19.1ns 0.727 0 0 4.74 KB
master ObjectExtractorSimpleBody net6.0 322ns 1.63ns 7.28ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 396ns 2.18ns 12.5ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 305ns 0.0335ns 0.126ns 0.0445 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.27μs 31.3ns 133ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.81μs 38.3ns 158ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.87μs 7.99ns 29.9ns 0.584 0 0 3.8 KB
#7697 AllCycleSimpleBody net6.0 1.13μs 1.05ns 3.95ns 0 0 0 1.22 KB
#7697 AllCycleSimpleBody netcoreapp3.1 1.38μs 7.89ns 49.9ns 0 0 0 1.2 KB
#7697 AllCycleSimpleBody net472 1μs 0.676ns 2.62ns 0.195 0 0 1.23 KB
#7697 AllCycleMoreComplexBody net6.0 7.23μs 35.3ns 158ns 0 0 0 4.72 KB
#7697 AllCycleMoreComplexBody netcoreapp3.1 8.88μs 41.9ns 168ns 0 0 0 4.62 KB
#7697 AllCycleMoreComplexBody net472 7.6μs 2.21ns 8.25ns 0.719 0 0 4.74 KB
#7697 ObjectExtractorSimpleBody net6.0 325ns 1.84ns 10.1ns 0 0 0 280 B
#7697 ObjectExtractorSimpleBody netcoreapp3.1 391ns 2.14ns 12.3ns 0 0 0 272 B
#7697 ObjectExtractorSimpleBody net472 305ns 0.0939ns 0.351ns 0.0431 0 0 281 B
#7697 ObjectExtractorMoreComplexBody net6.0 6.37μs 32.7ns 153ns 0 0 0 3.78 KB
#7697 ObjectExtractorMoreComplexBody netcoreapp3.1 7.85μs 35.2ns 136ns 0 0 0 3.69 KB
#7697 ObjectExtractorMoreComplexBody net472 6.83μs 7.56ns 29.3ns 0.576 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 75.6μs 228ns 884ns 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 97.9μs 119ns 446ns 0 0 0 32.4 KB
master EncodeArgs net472 109μs 17.9ns 69.3ns 4.91 0 0 32.5 KB
master EncodeLegacyArgs net6.0 145μs 8.91ns 33.3ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 200μs 186ns 722ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 265μs 38.7ns 150ns 0 0 0 2.14 KB
#7697 EncodeArgs net6.0 77.2μs 41.5ns 161ns 0 0 0 32.4 KB
#7697 EncodeArgs netcoreapp3.1 98.8μs 198ns 765ns 0 0 0 32.4 KB
#7697 EncodeArgs net472 109μs 27.9ns 108ns 4.89 0 0 32.5 KB
#7697 EncodeLegacyArgs net6.0 149μs 9.94ns 34.4ns 0 0 0 2.14 KB
#7697 EncodeLegacyArgs netcoreapp3.1 200μs 277ns 1.07μs 0 0 0 2.14 KB
#7697 EncodeLegacyArgs net472 265μs 24ns 92.8ns 0 0 0 2.15 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 427μs 909ns 3.15μs 0 0 0 4.55 KB
master RunWafRealisticBenchmark netcoreapp3.1 466μs 3.45μs 32.9μs 0 0 0 4.48 KB
master RunWafRealisticBenchmark net472 486μs 431ns 1.61μs 0 0 0 0 b
master RunWafRealisticBenchmarkWithAttack net6.0 310μs 1.39μs 4.99μs 0 0 0 2.24 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 318μs 1.07μs 6.83μs 0 0 0 2.22 KB
master RunWafRealisticBenchmarkWithAttack net472 364μs 413ns 1.55μs 0 0 0 0 b
#7697 RunWafRealisticBenchmark net6.0 430μs 1.26μs 4.71μs 0 0 0 4.55 KB
#7697 RunWafRealisticBenchmark netcoreapp3.1 451μs 2.58μs 19.2μs 0 0 0 4.48 KB
#7697 RunWafRealisticBenchmark net472 493μs 357ns 1.34μs 0 0 0 0 b
#7697 RunWafRealisticBenchmarkWithAttack net6.0 316μs 1μs 3.47μs 0 0 0 2.24 KB
#7697 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 354μs 4.03μs 39.1μs 0 0 0 2.22 KB
#7697 RunWafRealisticBenchmarkWithAttack net472 369μs 360ns 1.35μs 0 0 0 0 b
Benchmarks.Trace.AspNetCoreBenchmark - Unknown 🤷 Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 85.1μs 266ns 1.25μs 0 0 0 18.97 KB
master SendRequest netcoreapp3.1 97μs 324ns 1.86μs 0 0 0 21.19 KB
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#7697 SendRequest net6.0 85.3μs 174ns 675ns 0 0 0 18.97 KB
#7697 SendRequest netcoreapp3.1 96.9μs 189ns 1.24μs 0 0 0 21.18 KB
#7697 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master OriginalCharSlice net6.0 1.96ms 2.41μs 9.35μs 0 0 0 640 KB
master OriginalCharSlice netcoreapp3.1 3.87ms 863ns 3.34μs 0 0 0 640.05 KB
master OriginalCharSlice net472 2.63ms 419ns 1.57μs 0 0 0 638.98 KB
master OptimizedCharSlice net6.0 1.41ms 1.17μs 4.52μs 0 0 0 0 b
master OptimizedCharSlice netcoreapp3.1 2.83ms 785ns 2.94μs 0 0 0 0 b
master OptimizedCharSlice net472 1.99ms 966ns 3.48μs 0 0 0 0 b
master OptimizedCharSliceWithPool net6.0 1.06ms 445ns 1.72μs 0 0 0 0 b
master OptimizedCharSliceWithPool netcoreapp3.1 1.86ms 1.1μs 4.27μs 0 0 0 0 b
master OptimizedCharSliceWithPool net472 1.14ms 712ns 2.66μs 0 0 0 0 b
#7697 OriginalCharSlice net6.0 1.98ms 741ns 2.67μs 0 0 0 640 KB
#7697 OriginalCharSlice netcoreapp3.1 3.87ms 1.42μs 5.11μs 0 0 0 640.05 KB
#7697 OriginalCharSlice net472 2.7ms 795ns 3.08μs 0 0 0 638.98 KB
#7697 OptimizedCharSlice net6.0 1.45ms 473ns 1.64μs 0 0 0 0 b
#7697 OptimizedCharSlice netcoreapp3.1 2.73ms 630ns 2.36μs 0 0 0 0 b
#7697 OptimizedCharSlice net472 1.91ms 588ns 2.2μs 0 0 0 0 b
#7697 OptimizedCharSliceWithPool net6.0 1.1ms 477ns 1.85μs 0 0 0 0 b
#7697 OptimizedCharSliceWithPool netcoreapp3.1 1.87ms 1.52μs 5.88μs 0 0 0 0 b
#7697 OptimizedCharSliceWithPool net472 1.16ms 942ns 3.65μs 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Slower ⚠️ More allocations ⚠️

Slower ⚠️ in #7697

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 1.141 887,026.79 1,012,051.79

More allocations ⚠️ in #7697

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 55.47 KB 56.05 KB 577 B 1.04%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 665μs 871ns 3.14μs 0 0 0 41.69 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 640μs 3.08μs 11.9μs 0 0 0 42 KB
master WriteAndFlushEnrichedTraces net472 888μs 3.71μs 14.4μs 4.46 0 0 55.47 KB
#7697 WriteAndFlushEnrichedTraces net6.0 678μs 3.79μs 25.4μs 0 0 0 41.68 KB
#7697 WriteAndFlushEnrichedTraces netcoreapp3.1 683μs 1.43μs 5.16μs 0 0 0 41.88 KB
#7697 WriteAndFlushEnrichedTraces net472 1ms 5.12μs 25.1μs 4.46 0 0 56.05 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.96μs 2.24ns 8.68ns 0 0 0 968 B
master ExecuteNonQuery netcoreapp3.1 2.61μs 12.6ns 50.5ns 0 0 0 960 B
master ExecuteNonQuery net472 2.65μs 0.789ns 2.95ns 0.144 0 0 931 B
#7697 ExecuteNonQuery net6.0 1.88μs 5.2ns 20.1ns 0 0 0 968 B
#7697 ExecuteNonQuery netcoreapp3.1 2.42μs 11ns 44.1ns 0 0 0 960 B
#7697 ExecuteNonQuery net472 2.74μs 1.1ns 4.26ns 0.138 0 0 931 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.67μs 1.51ns 5.83ns 0 0 0 952 B
master CallElasticsearch netcoreapp3.1 2.22μs 6.02ns 23.3ns 0 0 0 968 B
master CallElasticsearch net472 3.34μs 5.86ns 22.7ns 0.15 0 0 955 B
master CallElasticsearchAsync net6.0 1.88μs 2.82ns 10.9ns 0 0 0 928 B
master CallElasticsearchAsync netcoreapp3.1 2.48μs 7.51ns 29.1ns 0 0 0 1.02 KB
master CallElasticsearchAsync net472 3.47μs 4.91ns 19ns 0.156 0 0 1.01 KB
#7697 CallElasticsearch net6.0 1.71μs 0.643ns 2.23ns 0 0 0 952 B
#7697 CallElasticsearch netcoreapp3.1 2.21μs 9.64ns 37.4ns 0 0 0 968 B
#7697 CallElasticsearch net472 3.34μs 2.57ns 9.96ns 0.151 0 0 955 B
#7697 CallElasticsearchAsync net6.0 1.7μs 8.12ns 31.4ns 0 0 0 928 B
#7697 CallElasticsearchAsync netcoreapp3.1 2.5μs 7.44ns 28.8ns 0 0 0 1.02 KB
#7697 CallElasticsearchAsync net472 3.64μs 3.93ns 15.2ns 0.145 0 0 1.01 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.96μs 10.5ns 55.3ns 0 0 0 896 B
master ExecuteAsync netcoreapp3.1 2.34μs 9.24ns 32ns 0 0 0 896 B
master ExecuteAsync net472 2.55μs 1.43ns 5.55ns 0.128 0 0 858 B
#7697 ExecuteAsync net6.0 1.84μs 9.71ns 48.6ns 0 0 0 896 B
#7697 ExecuteAsync netcoreapp3.1 2.38μs 2.96ns 11.5ns 0 0 0 896 B
#7697 ExecuteAsync net472 2.58μs 3.68ns 14.2ns 0.129 0 0 858 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 14.1ns 52.7ns 0 0 0 2.29 KB
master SendAsync netcoreapp3.1 8.28μs 25.7ns 92.6ns 0 0 0 2.83 KB
master SendAsync net472 12μs 6.28ns 24.3ns 0.479 0 0 3.08 KB
#7697 SendAsync net6.0 6.82μs 2.51ns 9.03ns 0 0 0 2.29 KB
#7697 SendAsync netcoreapp3.1 8.47μs 17.2ns 64.5ns 0 0 0 2.83 KB
#7697 SendAsync net472 11.8μs 10ns 38.9ns 0.471 0 0 3.08 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7697

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 256.22 KB 275.27 KB 19.06 KB 7.44%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 256.95 KB 258.86 KB 1.91 KB 0.74%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 45.1μs 266ns 2.41μs 0 0 0 42.51 KB
master StringConcatBenchmark netcoreapp3.1 49.3μs 272ns 1.82μs 0 0 0 42.54 KB
master StringConcatBenchmark net472 56.7μs 259ns 1.04μs 0 0 0 49.15 KB
master StringConcatAspectBenchmark net6.0 463μs 2.31μs 10.6μs 0 0 0 256.95 KB
master StringConcatAspectBenchmark netcoreapp3.1 456μs 6.65μs 65.5μs 0 0 0 256.22 KB
master StringConcatAspectBenchmark net472 399μs 2.18μs 18.3μs 0 0 0 270.34 KB
#7697 StringConcatBenchmark net6.0 45.3μs 251ns 1.55μs 0 0 0 42.51 KB
#7697 StringConcatBenchmark netcoreapp3.1 50.6μs 257ns 1.69μs 0 0 0 42.54 KB
#7697 StringConcatBenchmark net472 57.1μs 107ns 386ns 0 0 0 49.15 KB
#7697 StringConcatAspectBenchmark net6.0 475μs 2.32μs 9.27μs 0 0 0 258.86 KB
#7697 StringConcatAspectBenchmark netcoreapp3.1 514μs 2.44μs 11.7μs 0 0 0 275.27 KB
#7697 StringConcatAspectBenchmark net472 402μs 2.19μs 12μs 0 0 0 270.34 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.67μs 1.78ns 6.88ns 0 0 0 1.69 KB
master EnrichedLog netcoreapp3.1 3.43μs 17.7ns 81.3ns 0 0 0 1.7 KB
master EnrichedLog net472 3.97μs 5.44ns 21.1ns 0.238 0 0 1.6 KB
#7697 EnrichedLog net6.0 2.7μs 14ns 68.8ns 0 0 0 1.69 KB
#7697 EnrichedLog netcoreapp3.1 3.52μs 17.3ns 79.2ns 0 0 0 1.7 KB
#7697 EnrichedLog net472 3.84μs 3.74ns 14.5ns 0.25 0 0 1.6 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 103ns 358ns 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 130μs 212ns 821ns 0 0 0 4.31 KB
master EnrichedLog net472 170μs 140ns 524ns 0 0 0 4.51 KB
#7697 EnrichedLog net6.0 124μs 167ns 601ns 0 0 0 4.31 KB
#7697 EnrichedLog netcoreapp3.1 131μs 257ns 928ns 0 0 0 4.31 KB
#7697 EnrichedLog net472 171μs 137ns 529ns 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 5.06μs 22.2ns 86ns 0 0 0 2.24 KB
master EnrichedLog netcoreapp3.1 6.91μs 6.93ns 26.9ns 0 0 0 2.26 KB
master EnrichedLog net472 7.52μs 7.83ns 30.3ns 0.3 0 0 2.05 KB
#7697 EnrichedLog net6.0 5.14μs 15.8ns 61.2ns 0 0 0 2.24 KB
#7697 EnrichedLog netcoreapp3.1 6.83μs 15.9ns 61.7ns 0 0 0 2.26 KB
#7697 EnrichedLog net472 7.68μs 8.49ns 31.8ns 0.308 0 0 2.05 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.87μs 9.26ns 42.4ns 0 0 0 1.12 KB
master SendReceive netcoreapp3.1 2.54μs 12ns 48ns 0 0 0 1.14 KB
master SendReceive net472 2.95μs 2.56ns 9.9ns 0.176 0 0 1.12 KB
#7697 SendReceive net6.0 1.95μs 0.52ns 2.01ns 0 0 0 1.12 KB
#7697 SendReceive netcoreapp3.1 2.51μs 12.1ns 49.9ns 0 0 0 1.14 KB
#7697 SendReceive net472 2.83μs 0.8ns 2.77ns 0.17 0 0 1.12 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.46μs 2.01ns 7.8ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.72μs 20.9ns 81.1ns 0 0 0 1.63 KB
master EnrichedLog net472 6.65μs 7.28ns 27.2ns 0.298 0 0 2.03 KB
#7697 EnrichedLog net6.0 4.38μs 10.4ns 36ns 0 0 0 1.58 KB
#7697 EnrichedLog netcoreapp3.1 5.77μs 10.5ns 40.8ns 0 0 0 1.63 KB
#7697 EnrichedLog net472 6.66μs 5.68ns 22ns 0.298 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 750ns 3.73ns 17.1ns 0 0 0 520 B
master StartFinishSpan netcoreapp3.1 963ns 5.2ns 28.5ns 0 0 0 520 B
master StartFinishSpan net472 899ns 0.12ns 0.434ns 0.0812 0 0 522 B
master StartFinishScope net6.0 914ns 1.11ns 4.16ns 0 0 0 640 B
master StartFinishScope netcoreapp3.1 1.14μs 5.95ns 26.6ns 0 0 0 640 B
master StartFinishScope net472 1.11μs 0.577ns 2.16ns 0.0948 0 0 602 B
master StartFinishTwoScopes net6.0 1.76μs 1.34ns 5.21ns 0 0 0 1.19 KB
master StartFinishTwoScopes netcoreapp3.1 2.17μs 11.2ns 53.6ns 0 0 0 1.19 KB
master StartFinishTwoScopes net472 2.14μs 1.58ns 6.11ns 0.161 0 0 1.08 KB
#7697 StartFinishSpan net6.0 767ns 0.139ns 0.519ns 0 0 0 520 B
#7697 StartFinishSpan netcoreapp3.1 954ns 5.06ns 27.3ns 0 0 0 520 B
#7697 StartFinishSpan net472 894ns 0.0775ns 0.3ns 0.0806 0 0 522 B
#7697 StartFinishScope net6.0 911ns 4.25ns 17.5ns 0 0 0 640 B
#7697 StartFinishScope netcoreapp3.1 1.16μs 1.92ns 7.44ns 0 0 0 640 B
#7697 StartFinishScope net472 1.07μs 0.155ns 0.582ns 0.0909 0 0 602 B
#7697 StartFinishTwoScopes net6.0 1.76μs 8.64ns 37.7ns 0 0 0 1.19 KB
#7697 StartFinishTwoScopes netcoreapp3.1 2.22μs 9.93ns 37.2ns 0 0 0 1.19 KB
#7697 StartFinishTwoScopes net472 2.1μs 3.27ns 12.7ns 0.168 0 0 1.08 KB
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 1.83ns 7.09ns 0 0 0 640 B
master RunOnMethodBegin netcoreapp3.1 1.44μs 6.31ns 24.4ns 0 0 0 640 B
master RunOnMethodBegin net472 1.44μs 0.503ns 1.88ns 0.0934 0 0 602 B
#7697 RunOnMethodBegin net6.0 1.05μs 1.04ns 3.88ns 0 0 0 640 B
#7697 RunOnMethodBegin netcoreapp3.1 1.35μs 5.01ns 19.4ns 0 0 0 640 B
#7697 RunOnMethodBegin net472 1.4μs 1.24ns 4.81ns 0.0908 0 0 602 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
Copy link

datadog-official bot commented Oct 22, 2025

⚠️ Tests

⚠️ Warnings

🧪 51 Tests failed

    GeneratesAliasSwitchWithLazyArrays from Datadog.Trace.SourceGenerators.Tests.ConfigKeyAliasesSwitcherGeneratorTests

GeneratesAliasSwitchWithLazyArrays from Datadog.Trace.SourceGenerators.Tests.ConfigKeyAliasesSwitcherGeneratorTests (Datadog)
Expected string "// <copyright company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
// <auto-generated/>

#nullable enable

namespace Datadog.Trace.Configuration;

...
GeneratesAliasSwitchWithLazyArrays from Datadog.Trace.SourceGenerators.Tests.ConfigKeyAliasesSwitcherGeneratorTests (Datadog)
Expected string "// <copyright company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
// <auto-generated/>

#nullable enable

namespace Datadog.Trace.Configuration;

...
View all

ℹ️ Info

❄️ No new flaky tests detected

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

@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 2 times, most recently from 8b47c49 to 9e16b03 Compare December 1, 2025 17:24
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 13b5134 to 20ca6c4 Compare December 2, 2025 11:41
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 9e16b03 to c5bd10a Compare December 2, 2025 11:41
@anna-git anna-git marked this pull request as ready for review December 2, 2025 16:53
@anna-git anna-git requested review from a team as code owners December 2, 2025 16:53
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 20ca6c4 to e405cee Compare December 3, 2025 19:32
@anna-git anna-git requested a review from a team as a code owner December 3, 2025 19:32
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from c5bd10a to 3cf027a Compare December 3, 2025 19:32
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from e405cee to b602955 Compare December 4, 2025 16:46
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 3cf027a to 9d07021 Compare December 4, 2025 16:46
@anna-git anna-git changed the title [Config Registry] 5/5 Replace manual ConfigurationKeys by generated ones in the whole solution [Config Registry] 5/6 Replace manual ConfigurationKeys by generated ones in the whole solution Dec 4, 2025
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from b602955 to 4356c31 Compare December 9, 2025 11:38
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 9d07021 to 3fae9ea Compare December 9, 2025 11:38
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 4356c31 to a5da240 Compare December 9, 2025 12:27
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch from 3fae9ea to faad2d7 Compare December 9, 2025 12:27
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from a5da240 to 30a170a Compare December 9, 2025 14:55
@anna-git anna-git force-pushed the anna/config-inversion-use-generate-config-keys-5 branch 2 times, most recently from 91a3181 to 95b0301 Compare December 9, 2025 15:43
@anna-git anna-git merged commit 95b0301 into anna/config-inversion-configuration-analyzers-4 Dec 9, 2025
1 of 2 checks passed
@anna-git anna-git force-pushed the anna/config-inversion-configuration-analyzers-4 branch from 30a170a to 346d13a Compare December 9, 2025 15:43
@anna-git anna-git deleted the anna/config-inversion-use-generate-config-keys-5 branch December 9, 2025 15:43
@anna-git anna-git restored the anna/config-inversion-use-generate-config-keys-5 branch December 9, 2025 15:45
anna-git added a commit that referenced this pull request Dec 10, 2025
…nes in the whole solution (#7931)

(This PR is actually
#7697 that accidentally
got closed)

## Context

Part of **Configuration Inversion (Step 5)** - Stack progress:
1. [#7548](#7548) - Add
GitLab step and JSON configuration file
2. [#7688](#7688) -
Cleanup configuration / platform keys + source generator
3. [#7698](#7698) -
Aliases handling via source generator
4. [#7689](#7689) -
Analyzers for platform and ConfigurationBuilder
5. **→ [#7931](#7697) -
Replace manual ConfigurationKeys by generated ones in the whole solution
(this PR)**
6. [#7932](#7932) -
Forbid use of System.Environment methods and adapt everywhere
7. [#7937](#7937) -
Integration names to generated keys

## Summary of changes

Fixed the
[ConfigurationKeysGenerator](cci:2://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace.SourceGenerators/Configuration/ConfigurationKeysGenerator.cs:21:0-958:1)
to properly read and apply the
[configuration_keys_mapping.json](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/configuration_keys_mapping.json:0:0-0:0)
file, and extracted common file header comments to a reusable constant.

**Key changes:**
- Fixed JSON array extraction in
[ParseMappingFile](cci:1://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace.SourceGenerators/Configuration/ConfigurationKeysGenerator.cs:350:4-524:5)
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](cci:2://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace.SourceGenerators/Configuration/ConfigurationKeysGenerator.cs:21:0-958:1)
and
[ConfigKeyAliasesSwitcherGenerator](cci:2://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace.SourceGenerators/Configuration/ConfigKeyAliasesSwitcherGenerator.cs:24:0-340:1)
to use the shared constant
- Added documentation as to how to add a key now

## Reason for change

The
[configuration_keys_mapping.json](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/configuration_keys_mapping.json:0:0-0:0)
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()](cci:1://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace.SourceGenerators/Configuration/JsonReader.cs:16:4-91:5)
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](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/configuration_keys_mapping.json:0:0-0:0)

## Other details

This fix ensures that the explicit naming conventions defined in
[configuration_keys_mapping.json](cci:7://file:///Users/anna.yafi/go/src/github.com/DataDog/dd-trace-dotnet3/tracer/src/Datadog.Trace/Configuration/configuration_keys_mapping.json:0:0-0:0)
are respected, maintaining consistency with the existing codebase and
preventing future confusion when constant names don't match their
expected values.

---------

Co-authored-by: Andrew Lock <[email protected]>
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