Skip to content

Conversation

@anna-git
Copy link
Contributor

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

Context

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

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

Summary

Adds source generator to auto-generate ConfigurationKeys from supported-configurations.json with name mapping to preserve existing constant names.

Changes

Source Generator:

  • ConfigurationKeysGenerator reads supported-configurations.json and supported-configurations-docs.yaml
  • Auto-generates ConfigurationKeys with nested product classes (AppSec, CIVisibility, OpenTelemetry, etc.)
  • Generates XML documentation and [Obsolete] attributes from JSON

Configuration Mapping:

  • configuration_keys_mapping.json maps env vars to original constant names (e.g., DD_TRACE_ENABLEDTraceEnabled)
  • Avoids refactoring hundreds of references across codebase

Updates:

  • Added missing DD_TRACE_ACTIVITY_LISTENER_ENABLED key
  • Committed temporary ConfigurationKeys2.g.cs files for validation

Motivation

Makes supported-configurations.json the single source of truth while preserving existing constant names to avoid massive refactoring.

Test Coverage

  • Added ConfigurationKeysGeneratorTests.cs with comprehensive unit tests
  • Tests validate generator output, XML documentation generation, and obsolete attribute application
  • Tests cover nested product classes, deprecations, and YAML documentation integration
  • All existing tests pass without modification

Related Work

Builds on #7548 (configuration registry) and #7688 (PlatformKeys separation + analyzers).

@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from bd34118 to cbb3933 Compare October 22, 2025 19:40
@anna-git anna-git force-pushed the anna/config-inversion-configuration-keys-rework-2 branch from 9501463 to 25e86cb Compare October 22, 2025 20:12
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from cbb3933 to 1cb1163 Compare October 22, 2025 20:12
@pr-commenter
Copy link

pr-commenter bot commented Oct 22, 2025

Benchmarks

Benchmarks Report for benchmark platform 🐌

Benchmarks for #7698 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.122
  • 6 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 ✔️ More allocations ⚠️

More allocations ⚠️ in #7698

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net472 6 KB 6.07 KB 71 B 1.18%
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net6.0 5.49 KB 5.54 KB 48 B 0.87%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 10.4μs 59.1ns 422ns 0 0 0 5.49 KB
master StartStopWithChild netcoreapp3.1 13.7μs 64.4ns 257ns 0 0 0 5.71 KB
master StartStopWithChild net472 22μs 120ns 655ns 0.963 0.428 0.107 6 KB
#7698 StartStopWithChild net6.0 10.5μs 57.7ns 341ns 0 0 0 5.54 KB
#7698 StartStopWithChild netcoreapp3.1 13.1μs 31.6ns 109ns 0 0 0 5.72 KB
#7698 StartStopWithChild net472 21.8μs 123ns 853ns 1.01 0.337 0.112 6.07 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 287ns 1.11μs 0 0 0 2.71 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 1.04ms 702ns 2.72μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 1.2ms 41.3ns 155ns 0 0 0 3.31 KB
#7698 WriteAndFlushEnrichedTraces net6.0 929μs 226ns 847ns 0 0 0 2.71 KB
#7698 WriteAndFlushEnrichedTraces netcoreapp3.1 1.03ms 100ns 361ns 0 0 0 2.7 KB
#7698 WriteAndFlushEnrichedTraces net472 1.2ms 59.4ns 230ns 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 329ns 1.65ns 7.55ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 403ns 2.07ns 9.46ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 302ns 0.0566ns 0.219ns 0.044 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.29μs 32.5ns 159ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.89μs 2.8ns 10.5ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.65μs 2.03ns 7.88ns 0.603 0 0 3.8 KB
#7698 AllCycleSimpleBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
#7698 AllCycleSimpleBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
#7698 AllCycleSimpleBody net472 N/A N/A N/A NaN NaN NaN 0 b
#7698 AllCycleMoreComplexBody net6.0 N/A N/A N/A NaN NaN NaN 0 b
#7698 AllCycleMoreComplexBody netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
#7698 AllCycleMoreComplexBody net472 N/A N/A N/A NaN NaN NaN 0 b
#7698 ObjectExtractorSimpleBody net6.0 318ns 1.74ns 10.2ns 0 0 0 280 B
#7698 ObjectExtractorSimpleBody netcoreapp3.1 399ns 2.16ns 11.8ns 0 0 0 272 B
#7698 ObjectExtractorSimpleBody net472 305ns 0.0329ns 0.127ns 0.0446 0 0 281 B
#7698 ObjectExtractorMoreComplexBody net6.0 6.35μs 31.4ns 137ns 0 0 0 3.78 KB
#7698 ObjectExtractorMoreComplexBody netcoreapp3.1 7.87μs 38.7ns 164ns 0 0 0 3.69 KB
#7698 ObjectExtractorMoreComplexBody net472 6.68μs 3.5ns 13.6ns 0.6 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.5μs 234ns 905ns 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 96.3μs 133ns 497ns 0 0 0 32.4 KB
master EncodeArgs net472 110μs 79ns 306ns 4.95 0 0 32.51 KB
master EncodeLegacyArgs net6.0 148μs 24.8ns 95.9ns 0 0 0 2.15 KB
master EncodeLegacyArgs netcoreapp3.1 203μs 641ns 2.48μs 0 0 0 2.14 KB
master EncodeLegacyArgs net472 263μs 28.3ns 110ns 0 0 0 2.16 KB
#7698 EncodeArgs net6.0 77.8μs 111ns 432ns 0 0 0 32.4 KB
#7698 EncodeArgs netcoreapp3.1 96.8μs 272ns 1.05μs 0 0 0 32.4 KB
#7698 EncodeArgs net472 112μs 20ns 77.5ns 5.03 0 0 32.51 KB
#7698 EncodeLegacyArgs net6.0 144μs 17.8ns 69.1ns 0 0 0 2.14 KB
#7698 EncodeLegacyArgs netcoreapp3.1 196μs 154ns 596ns 0 0 0 2.14 KB
#7698 EncodeLegacyArgs net472 264μs 24.3ns 94.1ns 0 0 0 2.17 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 399μs 72.6ns 272ns 0 0 0 4.55 KB
master RunWafRealisticBenchmark netcoreapp3.1 409μs 330ns 1.28μs 0 0 0 4.48 KB
master RunWafRealisticBenchmark net472 427μs 53.5ns 200ns 0 0 0 4.66 KB
master RunWafRealisticBenchmarkWithAttack net6.0 283μs 55.3ns 199ns 0 0 0 2.24 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 299μs 26.7ns 92.7ns 0 0 0 2.22 KB
master RunWafRealisticBenchmarkWithAttack net472 312μs 23.2ns 89.7ns 0 0 0 2.29 KB
#7698 RunWafRealisticBenchmark net6.0 401μs 93.9ns 351ns 0 0 0 4.56 KB
#7698 RunWafRealisticBenchmark netcoreapp3.1 413μs 831ns 3.22μs 0 0 0 4.48 KB
#7698 RunWafRealisticBenchmark net472 425μs 45.1ns 175ns 0 0 0 4.66 KB
#7698 RunWafRealisticBenchmarkWithAttack net6.0 290μs 45.3ns 170ns 0 0 0 2.24 KB
#7698 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 297μs 164ns 592ns 0 0 0 2.22 KB
#7698 RunWafRealisticBenchmarkWithAttack net472 311μs 41.2ns 154ns 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 61.9μs 48.8ns 189ns 0 0 0 14.52 KB
master SendRequest netcoreapp3.1 71.9μs 85.9ns 310ns 0 0 0 17.42 KB
master SendRequest net472 0.000409ns 0.000285ns 0.00107ns 0 0 0 0 b
#7698 SendRequest net6.0 61.3μs 43.1ns 155ns 0 0 0 14.52 KB
#7698 SendRequest netcoreapp3.1 71.9μs 261ns 1.01μs 0 0 0 17.42 KB
#7698 SendRequest net472 0.00371ns 0.0017ns 0.00657ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Slower ⚠️ More allocations ⚠️

Slower ⚠️ in #7698

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472 1.122 1,922,603.57 2,157,930.36

More allocations ⚠️ in #7698

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

Fewer allocations 🎉 in #7698

Benchmark Base Allocated Diff Allocated Change Change %
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.97ms 5.44μs 21.1μs 0 0 0 640 KB
master OriginalCharSlice netcoreapp3.1 2.1ms 5.36μs 19.3μs 0 0 0 640 KB
master OriginalCharSlice net472 2.72ms 453ns 1.75μs 100 0 0 641.95 KB
master OptimizedCharSlice net6.0 1.44ms 289ns 1.08μs 0 0 0 2 B
master OptimizedCharSlice netcoreapp3.1 1.67ms 663ns 2.57μs 0 0 0 1 B
master OptimizedCharSlice net472 1.92ms 181ns 701ns 0 0 0 73 B
master OptimizedCharSliceWithPool net6.0 850μs 11.8ns 42.6ns 0 0 0 4 B
master OptimizedCharSliceWithPool netcoreapp3.1 896μs 68ns 264ns 0 0 0 1 B
master OptimizedCharSliceWithPool net472 1.13ms 76.1ns 295ns 0 0 0 47 B
#7698 OriginalCharSlice net6.0 1.94ms 7.05μs 26.4μs 0 0 0 640.01 KB
#7698 OriginalCharSlice netcoreapp3.1 2.12ms 971ns 3.63μs 0 0 0 640 KB
#7698 OriginalCharSlice net472 2.61ms 2.18μs 8.46μs 100 0 0 641.95 KB
#7698 OptimizedCharSlice net6.0 1.45ms 118ns 441ns 0 0 0 4 B
#7698 OptimizedCharSlice netcoreapp3.1 1.71ms 334ns 1.3μs 0 0 0 1 B
#7698 OptimizedCharSlice net472 2.16ms 304ns 1.18μs 0 0 0 73 B
#7698 OptimizedCharSliceWithPool net6.0 846μs 35.1ns 136ns 0 0 0 4 B
#7698 OptimizedCharSliceWithPool netcoreapp3.1 812μs 286ns 1.11μs 0 0 0 0 b
#7698 OptimizedCharSliceWithPool net472 1.14ms 164ns 636ns 0 0 0 47 B
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #7698

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 57.04 KB 56.63 KB -409 B -0.72%
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 42.29 KB 41.73 KB -558 B -1.32%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 733μs 654ns 2.53μs 0 0 0 41.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 722μs 2.85μs 10.3μs 0 0 0 42.29 KB
master WriteAndFlushEnrichedTraces net472 944μs 5.35μs 38.9μs 8.33 0 0 57.04 KB
#7698 WriteAndFlushEnrichedTraces net6.0 722μs 1.9μs 6.84μs 0 0 0 41.75 KB
#7698 WriteAndFlushEnrichedTraces netcoreapp3.1 756μs 952ns 3.69μs 0 0 0 41.73 KB
#7698 WriteAndFlushEnrichedTraces net472 861μs 1.9μs 7.12μs 8.33 0 0 56.63 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.97μs 8.37ns 32.4ns 0 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 2.73μs 5.87ns 22.7ns 0 0 0 1.02 KB
master ExecuteNonQuery net472 2.86μs 3.83ns 14.8ns 0.154 0.014 0 987 B
#7698 ExecuteNonQuery net6.0 1.97μs 1.96ns 7.58ns 0 0 0 1.02 KB
#7698 ExecuteNonQuery netcoreapp3.1 2.75μs 11.3ns 43.9ns 0 0 0 1.02 KB
#7698 ExecuteNonQuery net472 2.84μs 9.2ns 35.6ns 0.157 0.0142 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.67μs 9.13ns 50ns 0 0 0 1.03 KB
master CallElasticsearch netcoreapp3.1 2.2μs 5.83ns 22.6ns 0 0 0 1.03 KB
master CallElasticsearch net472 3.64μs 3.08ns 11.5ns 0.147 0 0 1.04 KB
master CallElasticsearchAsync net6.0 1.91μs 8.93ns 34.6ns 0 0 0 1.01 KB
master CallElasticsearchAsync netcoreapp3.1 2.45μs 5.62ns 21.8ns 0 0 0 1.08 KB
master CallElasticsearchAsync net472 3.73μs 6.05ns 22.6ns 0.167 0 0 1.1 KB
#7698 CallElasticsearch net6.0 1.68μs 8.22ns 36.8ns 0 0 0 1.03 KB
#7698 CallElasticsearch netcoreapp3.1 2.2μs 8.28ns 28.7ns 0 0 0 1.03 KB
#7698 CallElasticsearch net472 3.65μs 1.11ns 4.31ns 0.164 0 0 1.04 KB
#7698 CallElasticsearchAsync net6.0 1.91μs 3.28ns 12.7ns 0 0 0 1.01 KB
#7698 CallElasticsearchAsync netcoreapp3.1 2.35μs 11.9ns 54.3ns 0 0 0 1.08 KB
#7698 CallElasticsearchAsync net472 3.62μs 6.28ns 24.3ns 0.164 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.92μs 6.41ns 24.8ns 0 0 0 952 B
master ExecuteAsync netcoreapp3.1 2.48μs 1.54ns 5.95ns 0 0 0 952 B
master ExecuteAsync net472 2.58μs 5.85ns 22.7ns 0.141 0 0 915 B
#7698 ExecuteAsync net6.0 1.88μs 9.32ns 40.6ns 0 0 0 952 B
#7698 ExecuteAsync netcoreapp3.1 2.51μs 8.17ns 31.6ns 0 0 0 952 B
#7698 ExecuteAsync net472 2.7μs 3.9ns 15.1ns 0.134 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.08μs 7.7ns 28.8ns 0 0 0 2.36 KB
master SendAsync netcoreapp3.1 8.41μs 28.8ns 112ns 0 0 0 2.9 KB
master SendAsync net472 12.6μs 8.25ns 32ns 0.502 0 0 3.18 KB
#7698 SendAsync net6.0 6.89μs 8.97ns 34.7ns 0 0 0 2.36 KB
#7698 SendAsync netcoreapp3.1 8.72μs 27.9ns 108ns 0 0 0 2.9 KB
#7698 SendAsync net472 12.6μs 11.7ns 45.5ns 0.503 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #7698

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 274.95 KB 272.79 KB -2.16 KB -0.79%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 44.89 KB 43.1 KB -1.78 KB -3.97%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 290.26 KB 278.53 KB -11.74 KB -4.04%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 42.4μs 234ns 1.64μs 0 0 0 44.89 KB
master StringConcatBenchmark netcoreapp3.1 52.8μs 490ns 4.75μs 0 0 0 42.85 KB
master StringConcatBenchmark net472 57.1μs 270ns 1.08μs 0 0 0 65.54 KB
master StringConcatAspectBenchmark net6.0 475μs 1.96μs 6.8μs 0 0 0 277.17 KB
master StringConcatAspectBenchmark netcoreapp3.1 446μs 5.28μs 52.3μs 0 0 0 274.95 KB
master StringConcatAspectBenchmark net472 402μs 2.08μs 9.75μs 0 0 0 290.26 KB
#7698 StringConcatBenchmark net6.0 41.1μs 211ns 967ns 0 0 0 43.1 KB
#7698 StringConcatBenchmark netcoreapp3.1 48μs 329ns 3.14μs 0 0 0 42.81 KB
#7698 StringConcatBenchmark net472 57.1μs 281ns 1.16μs 0 0 0 65.54 KB
#7698 StringConcatAspectBenchmark net6.0 507μs 2.44μs 9.77μs 0 0 0 277.26 KB
#7698 StringConcatAspectBenchmark netcoreapp3.1 451μs 6.66μs 65.9μs 0 0 0 272.79 KB
#7698 StringConcatAspectBenchmark net472 400μs 1.92μs 13.6μ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.63μs 14.5ns 84.4ns 0 0 0 1.7 KB
master EnrichedLog netcoreapp3.1 3.63μs 16.6ns 64.5ns 0 0 0 1.7 KB
master EnrichedLog net472 3.81μs 2.37ns 9.19ns 0.249 0 0 1.64 KB
#7698 EnrichedLog net6.0 2.65μs 14.4ns 83.8ns 0 0 0 1.7 KB
#7698 EnrichedLog netcoreapp3.1 3.72μs 13.8ns 53.3ns 0 0 0 1.7 KB
#7698 EnrichedLog net472 3.88μs 4.8ns 18.6ns 0.253 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 125μs 119ns 429ns 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 128μs 212ns 763ns 0 0 0 4.31 KB
master EnrichedLog net472 167μs 175ns 632ns 0 0 0 4.52 KB
#7698 EnrichedLog net6.0 128μs 188ns 728ns 0 0 0 4.31 KB
#7698 EnrichedLog netcoreapp3.1 132μs 267ns 1.04μs 0 0 0 4.31 KB
#7698 EnrichedLog net472 172μs 366ns 1.42μs 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.98μs 3.48ns 12.6ns 0 0 0 2.26 KB
master EnrichedLog netcoreapp3.1 6.95μs 7.05ns 27.3ns 0 0 0 2.26 KB
master EnrichedLog net472 7.65μs 3.26ns 12.2ns 0.305 0 0 2.08 KB
#7698 EnrichedLog net6.0 5.08μs 3.77ns 14.1ns 0 0 0 2.26 KB
#7698 EnrichedLog netcoreapp3.1 6.88μs 8.87ns 34.4ns 0 0 0 2.26 KB
#7698 EnrichedLog net472 7.58μs 6.82ns 26.4ns 0.301 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 2.05μs 6.87ns 26.6ns 0 0 0 1.2 KB
master SendReceive netcoreapp3.1 2.68μs 11.6ns 45ns 0 0 0 1.2 KB
master SendReceive net472 2.99μs 2.81ns 10.9ns 0.179 0 0 1.2 KB
#7698 SendReceive net6.0 1.99μs 1.08ns 4.2ns 0 0 0 1.2 KB
#7698 SendReceive netcoreapp3.1 2.61μs 12.7ns 53.7ns 0 0 0 1.2 KB
#7698 SendReceive net472 2.99μs 2.59ns 10ns 0.18 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.58μs 6.9ns 26.7ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.71μs 19.5ns 75.3ns 0 0 0 1.63 KB
master EnrichedLog net472 6.51μs 8.36ns 32.4ns 0.292 0 0 2.03 KB
#7698 EnrichedLog net6.0 4.24μs 6.79ns 26.3ns 0 0 0 1.58 KB
#7698 EnrichedLog netcoreapp3.1 5.73μs 22.2ns 86.1ns 0 0 0 1.63 KB
#7698 EnrichedLog net472 6.48μs 5.05ns 18.9ns 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 809ns 3.98ns 17.3ns 0 0 0 576 B
master StartFinishSpan netcoreapp3.1 968ns 0.822ns 3.08ns 0 0 0 576 B
master StartFinishSpan net472 956ns 0.294ns 1.06ns 0.0908 0 0 578 B
master StartFinishScope net6.0 922ns 5.03ns 27.6ns 0 0 0 696 B
master StartFinishScope netcoreapp3.1 1.22μs 5.46ns 21.1ns 0 0 0 696 B
master StartFinishScope net472 1.15μs 0.681ns 2.46ns 0.103 0 0 658 B
#7698 StartFinishSpan net6.0 773ns 4.27ns 24.1ns 0 0 0 576 B
#7698 StartFinishSpan netcoreapp3.1 983ns 4.75ns 20.1ns 0 0 0 576 B
#7698 StartFinishSpan net472 951ns 0.133ns 0.515ns 0.0911 0 0 578 B
#7698 StartFinishScope net6.0 925ns 4.43ns 17.7ns 0 0 0 696 B
#7698 StartFinishScope netcoreapp3.1 1.2μs 2.66ns 9.58ns 0 0 0 696 B
#7698 StartFinishScope net472 1.14μs 0.526ns 2.04ns 0.103 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.15μs 6.06ns 29.7ns 0 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1.41μs 7.46ns 36.5ns 0 0 0 696 B
master RunOnMethodBegin net472 1.44μs 1.47ns 5.51ns 0.101 0 0 658 B
#7698 RunOnMethodBegin net6.0 1.09μs 1.41ns 5.44ns 0 0 0 696 B
#7698 RunOnMethodBegin netcoreapp3.1 1.44μs 7.43ns 34.8ns 0 0 0 696 B
#7698 RunOnMethodBegin net472 1.43μs 1.15ns 4.47ns 0.101 0 0 658 B

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

dd-trace-dotnet-ci-bot bot commented Oct 22, 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 (7698) - mean (72ms)  : 71, 73
     .   : milestone, 72,
    master - mean (79ms)  : 76, 82
     .   : milestone, 79,

    section Baseline
    This PR (7698) - mean (68ms)  : 67, 69
     .   : milestone, 68,
    master - mean (75ms)  : 73, 78
     .   : milestone, 75,

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (1,048ms)  : 995, 1101
     .   : milestone, 1048,
    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 (7698) - mean (106ms)  : 105, 107
     .   : milestone, 106,
    master - mean (118ms)  : 114, 121
     .   : milestone, 118,

    section Baseline
    This PR (7698) - mean (106ms)  : 104, 107
     .   : milestone, 106,
    master - mean (116ms)  : 112, 121
     .   : milestone, 116,

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (747ms)  : 724, 770
     .   : milestone, 747,
    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 (7698) - mean (94ms)  : 93, 95
     .   : milestone, 94,
    master - mean (104ms)  : 101, 107
     .   : milestone, 104,

    section Baseline
    This PR (7698) - mean (93ms)  : 91, 95
     .   : milestone, 93,
    master - mean (103ms)  : 100, 107
     .   : milestone, 103,

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (706ms)  : 675, 736
     .   : milestone, 706,
    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 (7698) - mean (92ms)  : 91, 93
     .   : milestone, 92,
    master - mean (105ms)  : 98, 112
     .   : milestone, 105,

    section Baseline
    This PR (7698) - mean (91ms)  : 89, 93
     .   : milestone, 91,
    master - mean (103ms)  : 98, 107
     .   : milestone, 103,

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (660ms)  : 645, 674
     .   : milestone, 660,
    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 (7698) - mean (196ms)  : 193, 198
     .   : milestone, 196,
    master - mean (196ms)  : 193, 199
     .   : milestone, 196,

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

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (1,161ms)  : 1101, 1220
     .   : milestone, 1161,
    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 (7698) - mean (277ms)  : 274, 280
     .   : milestone, 277,
    master - mean (279ms)  : 274, 284
     .   : milestone, 279,

    section Baseline
    This PR (7698) - mean (276ms)  : 272, 281
     .   : milestone, 276,
    master - mean (279ms)  : 273, 285
     .   : milestone, 279,

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (948ms)  : 893, 1002
     .   : milestone, 948,
    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 (7698) - mean (269ms)  : 266, 272
     .   : milestone, 269,
    master - mean (270ms)  : 266, 275
     .   : milestone, 270,

    section Baseline
    This PR (7698) - mean (269ms)  : 265, 273
     .   : milestone, 269,
    master - mean (270ms)  : 264, 276
     .   : milestone, 270,

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (922ms)  : 878, 966
     .   : milestone, 922,
    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 (7698) - mean (270ms)  : 264, 277
     .   : milestone, 270,
    master - mean (271ms)  : 266, 277
     .   : milestone, 271,

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

    section CallTarget+Inlining+NGEN
    This PR (7698) - mean (850ms)  : 830, 870
     .   : milestone, 850,
    master - mean (856ms)  : 839, 873
     .   : milestone, 856,

Loading

@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 51a880e to bc30cd6 Compare October 22, 2025 22:48
@datadog-official

This comment has been minimized.

@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from bc30cd6 to c57648c Compare October 23, 2025 10:19
@anna-git anna-git changed the title [ConfigRegistry] Aliases handling via source generator [ConfigRegistry] Generate ConfigurationKeys from json and yaml file for docs Oct 23, 2025
@anna-git anna-git changed the title [ConfigRegistry] Generate ConfigurationKeys from json and yaml file for docs [ConfigRegistry] Generate ConfigurationKeys with source generator Oct 23, 2025
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch 3 times, most recently from 2133185 to 13488c5 Compare October 23, 2025 12:16
@anna-git anna-git force-pushed the anna/config-inversion-configuration-keys-rework-2 branch from 75c1854 to 631521a Compare October 23, 2025 13:26
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch from 13488c5 to a31063c Compare October 23, 2025 13:26
@anna-git anna-git changed the title [ConfigRegistry] Generate ConfigurationKeys with source generator [ConfigRegistry] 3/5 Generate ConfigurationKeys with source generator Oct 23, 2025
@anna-git anna-git marked this pull request as ready for review October 24, 2025 10:26
@anna-git anna-git requested review from a team as code owners October 24, 2025 10:26
@lucaspimentel
Copy link
Member

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@anna-git anna-git requested review from a team as code owners October 27, 2025 14:20
@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-keys-rework-2 branch from 346726a to e3b3d12 Compare October 27, 2025 19:21
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch 2 times, most recently from 5018466 to 783a308 Compare October 27, 2025 20:56
@anna-git anna-git force-pushed the anna/config-inversion-configuration-keys-rework-2 branch from e3b3d12 to 394dace Compare October 28, 2025 14:33
@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-keys-rework-2 branch from 394dace to c8b7ab3 Compare October 28, 2025 14:55
@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 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
.WithTrackingName(TrackingNames.ConfigurationKeysGenMappingAdditionalText);

// Combine all files
var combinedFiles = jsonFile.Collect().Combine(yamlFile.Collect()).Combine(mappingFile.Collect());
Copy link
Member

Choose a reason for hiding this comment

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

Instead of the multiple stages here you could do something like this:

var Files = context.AdditionalTextsProvider
                              .Where(static file => Path.GetFileName(file.Path).Equals(SupportedConfigurationsFileName, StringComparison.OrdinalIgnoreCase)
|| // yaml
|| // mapping
)
                              .WithTrackingName(TrackingNames.AllFiles)
.Collect()
.Select(allFiles => 
{
// find and check for the files here
}

Copy link
Contributor Author

@anna-git anna-git Oct 30, 2025

Choose a reason for hiding this comment

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

changed in ed3a6bc

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, LGTM.

The generation work is somewhat heavy so I was just randomly wondering if we should try to add some sort of caching layer to not-regenerate everything on the first project load if nothing has changed, but I'm not sure exactly how to do that or anything right now, so just mentioning it as food for thought 😄

(string.Empty, null, null),
new EquatableArray<DiagnosticInfo>(
[
CreateDiagnosticInfo("DDSG0005", "Configuration file not found", $"The file '{SupportedConfigurationsFileName}' was not found. Make sure the supported-configurations.json file exists and is included as an AdditionalFile.", DiagnosticSeverity.Error)
Copy link
Member

Choose a reason for hiding this comment

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

Just FYI, best practices for source generators now is to not emit diagnostics, because locations can change somewhat dynamically. Don't think it's an issue here though because you don't actually have any associated locations here, and we shouldn't ever hit this path anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good to know thanks!

yamlContent = yamlResult.Value;
}

// YAML is optional, so we don't fail if it has errors
Copy link
Member

Choose a reason for hiding this comment

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

Optional, but we already found it, so we should probably bail if we can't read it?

Copy link
Contributor Author

@anna-git anna-git Oct 30, 2025

Choose a reason for hiding this comment

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

yep, changed in 6ccb01e

var sb = new StringBuilder();

AppendFileHeader(sb);
sb.AppendLine($"namespace {Namespace};");
Copy link
Member

Choose a reason for hiding this comment

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

nit: never use string interpolation with StringBuilder, just use Append(). Otherwise you're doing extra allocations. Applies to all the $"" cases in here 🙂

Also, always use ';' instead of ";" when adding single characters:

Suggested change
sb.AppendLine($"namespace {Namespace};");
sb.Append("namespace ").Append(Namespace).AppendLine(';');

Copy link
Contributor Author

@anna-git anna-git Oct 30, 2025

Choose a reason for hiding this comment

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

changed in 6ccb01e

Comment on lines 511 to 532
private static string[] ProductNameEquivalents(string? productName)
{
if (string.IsNullOrEmpty(productName))
{
return new[] { string.Empty };
}

// we need to keep comparison case-sensitive as there are keys like TraceRemoveIntegrationServiceNamesEnabled and we don't want to strip Tracer
switch (productName)
{
case "AppSec":
return new[] { "Appsec" };
case "Tracer":
return new[] { "Trace" };
case "CiVisibility":
return new[] { "Civisibility" };
case "OpenTelemetry":
return new[] { "Otel" };
default:
return new[] { productName! };
}
}
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
private static string[] ProductNameEquivalents(string? productName)
{
if (string.IsNullOrEmpty(productName))
{
return new[] { string.Empty };
}
// we need to keep comparison case-sensitive as there are keys like TraceRemoveIntegrationServiceNamesEnabled and we don't want to strip Tracer
switch (productName)
{
case "AppSec":
return new[] { "Appsec" };
case "Tracer":
return new[] { "Trace" };
case "CiVisibility":
return new[] { "Civisibility" };
case "OpenTelemetry":
return new[] { "Otel" };
default:
return new[] { productName! };
}
}
private static string[] ProductNameEquivalents(string? productName)
=> productName switch
{
null or "" => [ string.Empty ],
"AppSec" => [ "Appsec" ],
"Tracer" => [ "Trace" ],
"CiVisibility" => [ "Civisibility" ],
"OpenTelemetry" => [ "Otel" ],
var x => [ x ],
}

Copy link
Contributor Author

@anna-git anna-git Oct 30, 2025

Choose a reason for hiding this comment

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

changed in 6ccb01e

<ItemGroup>
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5" PrivateAssets="all" />
Copy link
Member

Choose a reason for hiding this comment

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

Why 8.0.5? 🤔 Given we build with the .NET 10 SDK, I think you should use .NET 10? Also, you should check if this actually works in Visual Studio, because I worry it won't (VS builds using the .NET FX MSBuild by default).

e.g. the docs explain how his is a PITA 😅 https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.cookbook.md#use-functionality-from-nuget-packages

I wonder if we can just remove PrivateAssets="all"? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tested on Lucas Visual studio and it seemed to work fine 🤔

public static Dictionary<string, string> ParseDocumentation(string yamlContent)
{
var result = new Dictionary<string, string>();
var lines = yamlContent.Replace("\r\n", "\n").Split('\n');
Copy link
Member

Choose a reason for hiding this comment

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

tiny nit, if this code ends up running a lot, that's a bunch of extra allocations, maybe we could make it a span first and use that? If it's only going to run once on project load, then it's less of an issue (just makes initial loads slower)

Copy link
Contributor Author

@anna-git anna-git Oct 30, 2025

Choose a reason for hiding this comment

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

changed in 6ccb01e

Comment on lines 170 to 177

<ItemGroup>
<Folder Include="Generated\net461\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
<Folder Include="Generated\net6.0\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
<Folder Include="Generated\netcoreapp3.1\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
<Folder Include="Generated\netstandard2.0\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
</ItemGroup>

Copy link
Member

Choose a reason for hiding this comment

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

nit: we don't need these:

Suggested change
<ItemGroup>
<Folder Include="Generated\net461\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
<Folder Include="Generated\net6.0\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
<Folder Include="Generated\netcoreapp3.1\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
<Folder Include="Generated\netstandard2.0\Datadog.Trace.SourceGenerators\ConfigurationKeysGenerator\" />
</ItemGroup>

Copy link
Contributor Author

@anna-git anna-git Oct 30, 2025

Choose a reason for hiding this comment

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

fixed in 6ccb01e

Copy link
Member

Choose a reason for hiding this comment

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

Nice work on these tests 👍

@anna-git anna-git force-pushed the anna/config-inversion-configuration-keys-rework-2 branch from c8b7ab3 to 6e6573b Compare October 29, 2025 17:15
@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-keys-rework-2 branch from 6e6573b to 7c68ebe Compare October 29, 2025 17:48
@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 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
Base automatically changed from anna/config-inversion-configuration-keys-rework-2 to master October 30, 2025 17:12
@anna-git anna-git force-pushed the anna/config-inversion-configuration-aliases-switch-3 branch 2 times, most recently from d90d571 to 6ccb01e Compare October 30, 2025 20:46
@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
Copy link
Contributor Author

Nice, LGTM.

The generation work is somewhat heavy so I was just randomly wondering if we should try to add some sort of caching layer to not-regenerate everything on the first project load if nothing has changed, but I'm not sure exactly how to do that or anything right now, so just mentioning it as food for thought 😄

like keeping a file somewhere containing a hash of the 3 files? and comparing the hash on load?
Maybe if we see build is too long, we could try adding it later to cut down some time?

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