Skip to content

Conversation

@andrewlock
Copy link
Member

@andrewlock andrewlock commented Sep 18, 2025

Summary of changes

  • Expose DefaultServiceName on MutableSettings instead of on TracerManager
  • Expose MutableSettings on PerTraceSettings

Reason for change

The DefaultServiceName depends on ServiceName, which can change at runtime, so MutableSettings seems like the best place for it (eventually we will only have a single TracerManager and TracerSettings per lifetime

Note that this also solves an existing edge-case bug when customers do config in code and already-finished traces are serialized with the "incorrect" default service name.

Implementation details

Mostly commit-by-commit but:

  • Move the "fallback application name" calculation to a helper class
  • Expose the fallback application name on TracerSettings
    • Created as a Lazy<> because this calculation can be kind of expensive, and isn't necessary if the customer specifies a service name.
    • Exposed on TracerSettings because it doesn't change
  • Expose DefaultServiceName on MutableSettings instead of TracerManager.
  • Update usages to point to the new location

Additionally, there are some places where I believe we were "incorrectly" using the DD_SERVICE value, and ignoring the real fallback name.

  • Service Discovery's StoreTracerMetadata - @anna-git can you confirm if I'm correct that this should be using the "calculated" service name as a fallback?
  • TraceExporterConfiguration - @ganeshnj, same question, can you confirm that we should be passing the "calculated" service name, not just the "explictly set" service name?

One additional aspect I think we should consider:

  • Currently we're calling NormalizeService(serviceName) in a few places. Is there any reason we shouldn't be always normalizing the service name?
  • e.g. why don't we normalize DefaultServiceName automatically?

Test coverage

Covered by existing tests generally

Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-819

Part of a config stack

@andrewlock andrewlock added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:refactor labels Sep 18, 2025
@andrewlock
Copy link
Member Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Hooray!

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, or 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 fix this CI failure" or "@codex address that feedback".

@datadog-datadog-prod-us1

This comment has been minimized.

@andrewlock andrewlock marked this pull request as ready for review September 18, 2025 12:01
@andrewlock andrewlock requested review from a team as code owners September 18, 2025 12:01
@andrewlock andrewlock force-pushed the andrew/settings/3c-move-default-service-name branch 2 times, most recently from 18a7270 to 12dfa73 Compare September 18, 2025 14:04
@andrewlock andrewlock force-pushed the andrew/settings/3b-extract-mutable-settings branch from 2948606 to e3af174 Compare September 18, 2025 14:04
@dd-trace-dotnet-ci-bot
Copy link

dd-trace-dotnet-ci-bot bot commented Sep 18, 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 (7530) - mean (72ms)  : 70, 73
     .   : milestone, 72,
    master - mean (72ms)  : 70, 73
     .   : milestone, 72,

    section Baseline
    This PR (7530) - mean (68ms)  : 66, 70
     .   : milestone, 68,
    master - mean (68ms)  : 66, 70
     .   : milestone, 68,

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (1,048ms)  : 1005, 1090
     .   : milestone, 1048,
    master - mean (1,041ms)  : 1004, 1078
     .   : milestone, 1041,

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

    section Baseline
    This PR (7530) - mean (105ms)  : 103, 108
     .   : milestone, 105,
    master - mean (105ms)  : 103, 107
     .   : milestone, 105,

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (743ms)  : 719, 767
     .   : milestone, 743,
    master - mean (741ms)  : 717, 764
     .   : milestone, 741,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7530) - mean (101ms)  : 100, 102
     .   : milestone, 101,
    master - mean (101ms)  : 100, 102
     .   : milestone, 101,

    section Baseline
    This PR (7530) - mean (100ms)  : 97, 103
     .   : milestone, 100,
    master - mean (99ms)  : 97, 102
     .   : milestone, 99,

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (771ms)  : 738, 804
     .   : milestone, 771,
    master - mean (775ms)  : 744, 805
     .   : milestone, 775,

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

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

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (658ms)  : 646, 670
     .   : milestone, 658,
    master - mean (663ms)  : 646, 680
     .   : milestone, 663,

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

    section Baseline
    This PR (7530) - mean (192ms)  : 188, 197
     .   : milestone, 192,
    master - mean (192ms)  : 188, 197
     .   : milestone, 192,

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (1,169ms)  : 1111, 1226
     .   : milestone, 1169,
    master - mean (1,163ms)  : 1107, 1219
     .   : milestone, 1163,

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

    section Baseline
    This PR (7530) - mean (276ms)  : 270, 283
     .   : milestone, 276,
    master - mean (276ms)  : 271, 282
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (944ms)  : 903, 984
     .   : milestone, 944,
    master - mean (948ms)  : 909, 988
     .   : milestone, 948,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7530) - mean (279ms)  : 275, 284
     .   : milestone, 279,
    master - mean (280ms)  : 277, 283
     .   : milestone, 280,

    section Baseline
    This PR (7530) - mean (279ms)  : 275, 284
     .   : milestone, 279,
    master - mean (281ms)  : 276, 286
     .   : milestone, 281,

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (990ms)  : 944, 1037
     .   : milestone, 990,
    master - mean (995ms)  : 959, 1032
     .   : milestone, 995,

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

    section Baseline
    This PR (7530) - mean (268ms)  : 264, 273
     .   : milestone, 268,
    master - mean (269ms)  : 263, 275
     .   : milestone, 269,

    section CallTarget+Inlining+NGEN
    This PR (7530) - mean (847ms)  : 828, 867
     .   : milestone, 847,
    master - mean (857ms)  : 839, 875
     .   : milestone, 857,

Loading

@andrewlock andrewlock force-pushed the andrew/settings/3c-move-default-service-name branch from 12dfa73 to e4a1dbb Compare September 19, 2025 10:22
@andrewlock andrewlock requested review from a team as code owners September 19, 2025 10:22
@andrewlock andrewlock requested review from zacharycmontoya and removed request for a team September 19, 2025 10:22
@andrewlock andrewlock force-pushed the andrew/settings/3b-extract-mutable-settings branch from e3af174 to 849c9c6 Compare September 19, 2025 10:22
@andrewlock andrewlock force-pushed the andrew/settings/3c-move-default-service-name branch from e4a1dbb to f62f8b4 Compare September 19, 2025 14:06
@andrewlock andrewlock force-pushed the andrew/settings/3b-extract-mutable-settings branch from 849c9c6 to 3b77310 Compare September 19, 2025 14:06
@andrewlock andrewlock force-pushed the andrew/settings/3b-extract-mutable-settings branch from 5a11fe3 to 55fceea Compare October 14, 2025 16:41
@pr-commenter
Copy link

pr-commenter bot commented Oct 14, 2025

Benchmarks

Benchmarks Report for benchmark platform 🐌

Benchmarks for #7530 compared to master:

  • 2 benchmarks are slower, with geometric mean 1.669
  • 6 benchmarks have fewer allocations
  • 8 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 #7530

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net472 6.14 KB 6.1 KB -44 B -0.72%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 10.8μs 60.6ns 388ns 0 0 0 5.52 KB
master StartStopWithChild netcoreapp3.1 13.8μs 66.9ns 291ns 0 0 0 5.75 KB
master StartStopWithChild net472 21.6μs 99.1ns 371ns 0.877 0.219 0 6.14 KB
#7530 StartStopWithChild net6.0 11.2μs 53.3ns 213ns 0 0 0 5.51 KB
#7530 StartStopWithChild netcoreapp3.1 13.3μs 66.5ns 305ns 0 0 0 5.72 KB
#7530 StartStopWithChild net472 21.9μs 119ns 725ns 0.877 0.329 0 6.1 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 936μs 244ns 945ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 1.02ms 111ns 416ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 1.19ms 73.9ns 277ns 0 0 0 3.31 KB
#7530 WriteAndFlushEnrichedTraces net6.0 931μs 137ns 514ns 0 0 0 2.71 KB
#7530 WriteAndFlushEnrichedTraces netcoreapp3.1 1.02ms 91.4ns 354ns 0 0 0 2.7 KB
#7530 WriteAndFlushEnrichedTraces net472 1.18ms 53.5ns 200ns 0 0 0 3.31 KB
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7530

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑net472 203.96 KB 206.3 KB 2.34 KB 1.15%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑net472 207.5 KB 209.83 KB 2.33 KB 1.12%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑net6.0 178.25 KB 180.01 KB 1.76 KB 0.99%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody‑netcoreapp3.1 184.01 KB 185.8 KB 1.79 KB 0.97%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑net6.0 181.77 KB 183.53 KB 1.76 KB 0.97%
Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody‑netcoreapp3.1 187.44 KB 189.23 KB 1.79 KB 0.96%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 344μs 619ns 2.4μs 0 0 0 178.25 KB
master AllCycleSimpleBody netcoreapp3.1 506μs 1.75μs 6.79μs 0 0 0 184.01 KB
master AllCycleSimpleBody net472 459μs 99.1ns 384ns 31.2 0 0 203.96 KB
master AllCycleMoreComplexBody net6.0 349μs 1.27μs 4.92μs 0 0 0 181.77 KB
master AllCycleMoreComplexBody netcoreapp3.1 524μs 1.37μs 5.12μs 0 0 0 187.44 KB
master AllCycleMoreComplexBody net472 470μs 170ns 659ns 32.4 0 0 207.5 KB
master ObjectExtractorSimpleBody net6.0 330ns 1.7ns 8.15ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 398ns 2.2ns 12.7ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 292ns 0.0479ns 0.179ns 0.0443 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.26μs 31.7ns 152ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.7μs 31.1ns 121ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.65μs 3.8ns 14.7ns 0.599 0 0 3.8 KB
#7530 AllCycleSimpleBody net6.0 363μs 556ns 2.15μs 0 0 0 180.01 KB
#7530 AllCycleSimpleBody netcoreapp3.1 537μs 1.46μs 5.66μs 0 0 0 185.8 KB
#7530 AllCycleSimpleBody net472 472μs 161ns 624ns 32.4 0 0 206.3 KB
#7530 AllCycleMoreComplexBody net6.0 371μs 1.83μs 7.75μs 0 0 0 183.53 KB
#7530 AllCycleMoreComplexBody netcoreapp3.1 507μs 1.43μs 5.53μs 0 0 0 189.23 KB
#7530 AllCycleMoreComplexBody net472 482μs 103ns 371ns 31.2 0 0 209.83 KB
#7530 ObjectExtractorSimpleBody net6.0 335ns 0.434ns 1.68ns 0 0 0 280 B
#7530 ObjectExtractorSimpleBody netcoreapp3.1 399ns 1.96ns 8.34ns 0 0 0 272 B
#7530 ObjectExtractorSimpleBody net472 302ns 0.0143ns 0.0515ns 0.0446 0 0 281 B
#7530 ObjectExtractorMoreComplexBody net6.0 6.35μs 27.6ns 103ns 0 0 0 3.78 KB
#7530 ObjectExtractorMoreComplexBody netcoreapp3.1 7.87μs 30.3ns 117ns 0 0 0 3.69 KB
#7530 ObjectExtractorMoreComplexBody net472 6.63μs 2.2ns 8.52ns 0.597 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 77μs 119ns 447ns 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 98.2μs 172ns 665ns 0 0 0 32.4 KB
master EncodeArgs net472 112μs 23ns 89.2ns 5.05 0 0 32.51 KB
master EncodeLegacyArgs net6.0 145μs 10.1ns 36.4ns 0 0 0 2.15 KB
master EncodeLegacyArgs netcoreapp3.1 198μs 136ns 510ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 263μs 288ns 1.12μs 0 0 0 2.16 KB
#7530 EncodeArgs net6.0 77μs 226ns 847ns 0 0 0 32.4 KB
#7530 EncodeArgs netcoreapp3.1 97.8μs 33.6ns 130ns 0 0 0 32.4 KB
#7530 EncodeArgs net472 108μs 26.7ns 103ns 4.89 0 0 32.51 KB
#7530 EncodeLegacyArgs net6.0 144μs 16ns 60ns 0 0 0 2.15 KB
#7530 EncodeLegacyArgs netcoreapp3.1 198μs 203ns 786ns 0 0 0 2.14 KB
#7530 EncodeLegacyArgs net472 264μs 32.9ns 127ns 0 0 0 2.16 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #7530

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑netcoreapp3.1 2.458 298,302.75 733,104.09

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 413μs 884ns 3.42μs 0 0 0 4.56 KB
master RunWafRealisticBenchmark netcoreapp3.1 418μs 395ns 1.37μs 0 0 0 4.48 KB
master RunWafRealisticBenchmark net472 431μs 42.7ns 165ns 0 0 0 4.66 KB
master RunWafRealisticBenchmarkWithAttack net6.0 293μs 29.5ns 111ns 0 0 0 2.24 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 298μs 28.2ns 102ns 0 0 0 2.22 KB
master RunWafRealisticBenchmarkWithAttack net472 308μs 40.8ns 158ns 0 0 0 2.29 KB
#7530 RunWafRealisticBenchmark net6.0 395μs 43ns 161ns 0 0 0 4.56 KB
#7530 RunWafRealisticBenchmark netcoreapp3.1 409μs 138ns 480ns 0 0 0 4.48 KB
#7530 RunWafRealisticBenchmark net472 433μs 45.7ns 158ns 0 0 0 4.66 KB
#7530 RunWafRealisticBenchmarkWithAttack net6.0 284μs 19.5ns 75.3ns 0 0 0 2.24 KB
#7530 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 669μs 12.3μs 123μs 0 0 0 2.22 KB
#7530 RunWafRealisticBenchmarkWithAttack net472 316μs 44.3ns 172ns 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 60.8μs 64.7ns 224ns 0 0 0 14.52 KB
master SendRequest netcoreapp3.1 71.2μs 63.5ns 238ns 0 0 0 17.42 KB
master SendRequest net472 0.00177ns 0.000985ns 0.00381ns 0 0 0 0 b
#7530 SendRequest net6.0 60.6μs 68.7ns 238ns 0 0 0 14.52 KB
#7530 SendRequest netcoreapp3.1 72.2μs 298ns 1.63μs 0 0 0 17.42 KB
#7530 SendRequest net472 0.00225ns 0.000936ns 0.00362ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7530

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑netcoreapp3.1 0 b 1 B 1 B

Fewer allocations 🎉 in #7530

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net6.0 7 B 4 B -3 B -42.86%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472 73 B 0 b -73 B -100.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net472 47 B 0 b -47 B -100.00%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master OriginalCharSlice net6.0 1.92ms 333ns 1.25μs 0 0 0 640.01 KB
master OriginalCharSlice netcoreapp3.1 2.14ms 9.15μs 35.4μs 0 0 0 640 KB
master OriginalCharSlice net472 2.56ms 161ns 604ns 100 0 0 641.95 KB
master OptimizedCharSlice net6.0 1.37ms 144ns 556ns 0 0 0 7 B
master OptimizedCharSlice netcoreapp3.1 1.68ms 237ns 887ns 0 0 0 1 B
master OptimizedCharSlice net472 1.93ms 164ns 613ns 0 0 0 73 B
master OptimizedCharSliceWithPool net6.0 832μs 35.9ns 139ns 0 0 0 3 B
master OptimizedCharSliceWithPool netcoreapp3.1 874μs 41.4ns 160ns 0 0 0 0 b
master OptimizedCharSliceWithPool net472 1.15ms 124ns 479ns 0 0 0 47 B
#7530 OriginalCharSlice net6.0 1.98ms 675ns 2.62μs 0 0 0 640.01 KB
#7530 OriginalCharSlice netcoreapp3.1 2.11ms 4.28μs 16.6μs 0 0 0 640 KB
#7530 OriginalCharSlice net472 2.63ms 455ns 1.76μs 100 0 0 641.95 KB
#7530 OptimizedCharSlice net6.0 1.34ms 242ns 938ns 0 0 0 4 B
#7530 OptimizedCharSlice netcoreapp3.1 1.75ms 323ns 1.25μs 0 0 0 1 B
#7530 OptimizedCharSlice net472 2.05ms 331ns 1.28μs 0 0 0 0 b
#7530 OptimizedCharSliceWithPool net6.0 871μs 64.3ns 241ns 0 0 0 3 B
#7530 OptimizedCharSliceWithPool netcoreapp3.1 839μs 99.3ns 385ns 0 0 0 1 B
#7530 OptimizedCharSliceWithPool net472 1.13ms 115ns 444ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 679μs 2.56μs 9.9μs 0 0 0 41.68 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 725μs 4.23μs 41.7μs 0 0 0 41.76 KB
master WriteAndFlushEnrichedTraces net472 870μs 3.57μs 13.8μs 8.33 0 0 56.18 KB
#7530 WriteAndFlushEnrichedTraces net6.0 694μs 3.49μs 16μs 0 0 0 41.57 KB
#7530 WriteAndFlushEnrichedTraces netcoreapp3.1 763μs 4.93μs 49.3μs 0 0 0 41.86 KB
#7530 WriteAndFlushEnrichedTraces net472 893μs 2.13μs 7.98μs 8.33 0 0 56.39 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.92μs 6.45ns 25ns 0 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 2.55μs 2.48ns 9.62ns 0 0 0 1.02 KB
master ExecuteNonQuery net472 2.73μs 4.36ns 16.9ns 0.15 0.0137 0 987 B
#7530 ExecuteNonQuery net6.0 1.92μs 3.63ns 14ns 0 0 0 1.02 KB
#7530 ExecuteNonQuery netcoreapp3.1 2.63μs 2.04ns 7.62ns 0 0 0 1.02 KB
#7530 ExecuteNonQuery net472 2.71μs 3.2ns 12.4ns 0.149 0.0136 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.84μs 8.02ns 31.1ns 0 0 0 1.03 KB
master CallElasticsearch netcoreapp3.1 2.26μs 9.12ns 35.3ns 0 0 0 1.03 KB
master CallElasticsearch net472 3.56μs 2.23ns 8.35ns 0.161 0 0 1.04 KB
master CallElasticsearchAsync net6.0 1.9μs 9.03ns 37.2ns 0 0 0 1.01 KB
master CallElasticsearchAsync netcoreapp3.1 2.45μs 11.8ns 45.6ns 0 0 0 1.08 KB
master CallElasticsearchAsync net472 3.7μs 4.55ns 17.6ns 0.165 0 0 1.1 KB
#7530 CallElasticsearch net6.0 1.79μs 6.67ns 25.8ns 0 0 0 1.03 KB
#7530 CallElasticsearch netcoreapp3.1 2.3μs 11.1ns 48.4ns 0 0 0 1.03 KB
#7530 CallElasticsearch net472 3.52μs 1.15ns 4.29ns 0.159 0 0 1.04 KB
#7530 CallElasticsearchAsync net6.0 1.87μs 2.39ns 9.24ns 0 0 0 1.01 KB
#7530 CallElasticsearchAsync netcoreapp3.1 2.48μs 4.9ns 19ns 0 0 0 1.08 KB
#7530 CallElasticsearchAsync net472 3.82μs 3.52ns 13.6ns 0.172 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.89μs 9.47ns 42.4ns 0 0 0 952 B
master ExecuteAsync netcoreapp3.1 2.34μs 8.01ns 31ns 0 0 0 952 B
master ExecuteAsync net472 2.54μs 2.58ns 9.97ns 0.141 0 0 915 B
#7530 ExecuteAsync net6.0 1.9μs 0.605ns 2.34ns 0 0 0 952 B
#7530 ExecuteAsync netcoreapp3.1 2.39μs 6.52ns 25.2ns 0 0 0 952 B
#7530 ExecuteAsync net472 2.52μs 3.84ns 14.9ns 0.139 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 6.82μs 4.62ns 16.7ns 0 0 0 2.36 KB
master SendAsync netcoreapp3.1 8.45μs 33ns 128ns 0 0 0 2.9 KB
master SendAsync net472 12.2μs 7.73ns 29.9ns 0.487 0 0 3.18 KB
#7530 SendAsync net6.0 6.95μs 5.22ns 19.5ns 0 0 0 2.36 KB
#7530 SendAsync netcoreapp3.1 8.41μs 11.2ns 43.5ns 0 0 0 2.9 KB
#7530 SendAsync net472 12.2μs 11.1ns 43.1ns 0.488 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Slower ⚠️ More allocations ⚠️

Slower ⚠️ in #7530

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 1.133 467,250.00 529,500.00

More allocations ⚠️ in #7530

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑netcoreapp3.1 42.64 KB 42.9 KB 264 B 0.62%

Fewer allocations 🎉 in #7530

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 273.55 KB 255.91 KB -17.64 KB -6.45%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 275.41 KB 256.59 KB -18.82 KB -6.83%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 44.4μs 226ns 1.48μs 0 0 0 43.98 KB
master StringConcatBenchmark netcoreapp3.1 50.1μs 321ns 3.1μs 0 0 0 42.64 KB
master StringConcatBenchmark net472 56.5μs 255ns 989ns 0 0 0 57.34 KB
master StringConcatAspectBenchmark net6.0 471μs 2.47μs 12.6μs 0 0 0 273.55 KB
master StringConcatAspectBenchmark netcoreapp3.1 544μs 2.46μs 8.86μs 0 0 0 275.41 KB
master StringConcatAspectBenchmark net472 401μs 2.28μs 16.6μs 0 0 0 279.23 KB
#7530 StringConcatBenchmark net6.0 45.9μs 226ns 1.38μs 0 0 0 44.03 KB
#7530 StringConcatBenchmark netcoreapp3.1 46μs 251ns 1.4μs 0 0 0 42.9 KB
#7530 StringConcatBenchmark net472 58.1μs 281ns 1.09μs 0 0 0 57.34 KB
#7530 StringConcatAspectBenchmark net6.0 532μs 2.21μs 9.89μs 0 0 0 255.91 KB
#7530 StringConcatAspectBenchmark netcoreapp3.1 519μs 2.18μs 8.15μs 0 0 0 256.59 KB
#7530 StringConcatAspectBenchmark net472 405μs 2.16μs 12μ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.5μs 12.1ns 48.4ns 0 0 0 1.7 KB
master EnrichedLog netcoreapp3.1 3.55μs 17ns 65.9ns 0 0 0 1.7 KB
master EnrichedLog net472 3.73μs 1.73ns 6.71ns 0.243 0 0 1.64 KB
#7530 EnrichedLog net6.0 2.64μs 11.3ns 43.8ns 0 0 0 1.7 KB
#7530 EnrichedLog netcoreapp3.1 3.59μs 17.5ns 78.1ns 0 0 0 1.7 KB
#7530 EnrichedLog net472 3.76μs 1.98ns 7.4ns 0.245 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 122μs 39.3ns 147ns 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 127μs 87.3ns 302ns 0 0 0 4.31 KB
master EnrichedLog net472 165μs 76.4ns 296ns 0 0 0 4.51 KB
#7530 EnrichedLog net6.0 123μs 52.2ns 202ns 0 0 0 4.31 KB
#7530 EnrichedLog netcoreapp3.1 127μs 166ns 620ns 0 0 0 4.31 KB
#7530 EnrichedLog net472 168μs 69ns 267ns 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 5.23μs 19.4ns 75ns 0 0 0 2.26 KB
master EnrichedLog netcoreapp3.1 6.92μs 6.78ns 26.3ns 0 0 0 2.26 KB
master EnrichedLog net472 7.58μs 3.2ns 11.5ns 0.305 0 0 2.08 KB
#7530 EnrichedLog net6.0 5.03μs 3.41ns 13.2ns 0 0 0 2.26 KB
#7530 EnrichedLog netcoreapp3.1 6.7μs 13.9ns 53.7ns 0 0 0 2.26 KB
#7530 EnrichedLog net472 7.46μs 8.03ns 31.1ns 0.299 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.06μs 9.99ns 44.7ns 0 0 0 1.2 KB
master SendReceive netcoreapp3.1 2.67μs 13.6ns 59.2ns 0 0 0 1.2 KB
master SendReceive net472 3.13μs 2.96ns 11.5ns 0.188 0 0 1.2 KB
#7530 SendReceive net6.0 2.06μs 9.94ns 41ns 0 0 0 1.2 KB
#7530 SendReceive netcoreapp3.1 2.57μs 8.23ns 30.8ns 0 0 0 1.2 KB
#7530 SendReceive net472 3.24μs 6.96ns 27ns 0.178 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.21μs 15.4ns 57.8ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.35μs 20.2ns 78.2ns 0 0 0 1.63 KB
master EnrichedLog net472 6.42μs 6.03ns 23.4ns 0.32 0 0 2.03 KB
#7530 EnrichedLog net6.0 4.21μs 13.9ns 52.1ns 0 0 0 1.58 KB
#7530 EnrichedLog netcoreapp3.1 5.7μs 11.6ns 45ns 0 0 0 1.63 KB
#7530 EnrichedLog net472 6.5μs 7.56ns 28.3ns 0.291 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 733ns 3.78ns 17.7ns 0 0 0 576 B
master StartFinishSpan netcoreapp3.1 924ns 4.55ns 16.4ns 0 0 0 576 B
master StartFinishSpan net472 874ns 0.113ns 0.407ns 0.0916 0 0 578 B
master StartFinishScope net6.0 903ns 4.42ns 18.2ns 0 0 0 696 B
master StartFinishScope netcoreapp3.1 1.17μs 5.41ns 20.9ns 0 0 0 696 B
master StartFinishScope net472 1.08μs 0.991ns 3.84ns 0.103 0 0 658 B
#7530 StartFinishSpan net6.0 755ns 4.19ns 21.7ns 0 0 0 576 B
#7530 StartFinishSpan netcoreapp3.1 950ns 5.07ns 27.8ns 0 0 0 576 B
#7530 StartFinishSpan net472 910ns 0.415ns 1.55ns 0.0873 0 0 578 B
#7530 StartFinishScope net6.0 911ns 0.272ns 0.98ns 0 0 0 696 B
#7530 StartFinishScope netcoreapp3.1 1.16μs 5.89ns 25.7ns 0 0 0 696 B
#7530 StartFinishScope net472 1.13μs 0.228ns 0.885ns 0.102 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.03μs 0.369ns 1.33ns 0 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1.38μs 7.28ns 35.7ns 0 0 0 696 B
master RunOnMethodBegin net472 1.42μs 1.7ns 6.14ns 0.0998 0 0 658 B
#7530 RunOnMethodBegin net6.0 1.07μs 5.09ns 20.4ns 0 0 0 696 B
#7530 RunOnMethodBegin netcoreapp3.1 1.43μs 7.2ns 30.5ns 0 0 0 696 B
#7530 RunOnMethodBegin net472 1.49μs 0.937ns 3.51ns 0.0994 0 0 658 B

@andrewlock andrewlock force-pushed the andrew/settings/3c-move-default-service-name branch from 41bca93 to 9cb26d0 Compare October 15, 2025 07:32
@andrewlock andrewlock force-pushed the andrew/settings/3b-extract-mutable-settings branch from 55fceea to ba81d63 Compare October 15, 2025 07:32
@andrewlock andrewlock force-pushed the andrew/settings/3c-move-default-service-name branch from 9cb26d0 to 99df246 Compare October 15, 2025 09:56
@andrewlock andrewlock force-pushed the andrew/settings/3b-extract-mutable-settings branch from ba81d63 to c746722 Compare October 15, 2025 09:56
andrewlock added a commit that referenced this pull request Oct 15, 2025
## Summary of changes

Rebuild and re-assign `MutableSettings` when dynamic config (remote or
config in code) changes.

## Reason for change

This is part of a general stack to extract the "mutable" configuration
from static config that is fixed for the lifetime of the app. In the
[previous PR](#7522) we
moved mutable settings to their own type, but otherwise left things
unchanged and just rebuilt everything whenever anything changes.

In this PR we move towards combining the dynamic/code configuration,
handling changes by _only_ rebuilding the `MutableSettings` (not
`TracerSettings`) and handling all the fallout that causes for
telemetry.

This is very much still a "stop gap"; we still rebuild everything
(_except_ the `TracerSettings` object) when these settings changes.

## Implementation details

- Create "global" config sources for dynamic settings and code settings
- There's actually a bug today where we clobber dynamic settings if we
change things in code because we're not storing the sources globally.
- When dynamic config or config in code changes
- Create a new `MutableSettings` object based only on dynamic sources
(with a fallback for the "static" values)
  - For config in code, we also check for changes to `ExporterSettings`
- If there's no discernable changes, bail out - no need to tear down the
world
- If there _are_ changes, Mutate `TracerSettings`, and do the normal
"reconfigure everything"
- Remove the (now unused `ImmutableDynamicSettingsTests`)

Note that there are technically some behaviour changes in this PR:
- `useDefaultSources: false` only ignores env vars etc for values that
can be set through code. Other settings will always use the default
sources.
- `StatsComutationEnabled` can not be _set_ via code.

## Test coverage

This is still all technically a "refactoring", so should be covered by
existing tests 🤞

## Other details


https://datadoghq.atlassian.net/browse/LANGPLAT-819

Part of a config stack
- #7522
- #7652
- #7525 👈
- #7530
- #7532
- #7543
- #7544
Base automatically changed from andrew/settings/3b-extract-mutable-settings to master October 15, 2025 12:21
@andrewlock andrewlock force-pushed the andrew/settings/3c-move-default-service-name branch from 99df246 to 388a390 Compare October 15, 2025 12:22
{
"DD_TAGS"
};
private static readonly HashSet<string> DefaultExperimentalFeatures = ["DD_TAGS"];
Copy link
Member

Choose a reason for hiding this comment

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

❤️

@andrewlock andrewlock merged commit 050c019 into master Oct 15, 2025
157 checks passed
@andrewlock andrewlock deleted the andrew/settings/3c-move-default-service-name branch October 15, 2025 15:11
@github-actions github-actions bot added this to the vNext-v3 milestone Oct 15, 2025
andrewlock added a commit that referenced this pull request Oct 16, 2025
## Summary of changes

Don't pass a `Tracer` instance to `PerTraceSettings.GetServiceName()`
(as it's not required)

## Reason for change

Cleanup/simplify the code.

#7530 exposes `MutableSettings` and `DefaultServiceName` on
`PerTraceSettings`. Reading `DefaultServiceName` was the only reason
`GetServiceName()` took a `Tracer`, so this is now uneccessary.

## Implementation details

- Use `MutableSettings.DefaultServiceName` directly inside
`PerTraceSettings.GetServiceName()`
- Stop passing in `Tracer` instance
- Cleanup usages

## Test coverage

Covered by existing, just a refactoring

## Other details

Could have done it as part of #7530 but trying to keep things small!

https://datadoghq.atlassian.net/browse/LANGPLAT-819

Part of a config stack

- #7522
- #7525
- #7530
- #7532 👈
- #7543
- #7544
andrewlock added a commit that referenced this pull request Oct 22, 2025
…ropriate (#7543)

## Summary of changes

Fix usages of `Tracer.Instance.Settings` to use
`Tracer.Instance.CurrentTracerSettings.Settings` where appropriate

## Reason for change

This PR "fixes" the places that were previously grabbing the
environment/service etc from `TracerSettings` to use the
`MutableSettings` exposed via `CurrentTracerSettings` instead, as the
location where these settings will ultimately exist.

This is effectively still just a refactoring, but prepares for the point
where these settings aren't exposed on `TracerSettings` at all. The
updates in this PR are for cases where you _don't_ have long-lived
services, and rather need to do ad-hoc `Tracer.Instance` grabbing of the
setting values in a global context. Note too that many of these places
_could_ be updated in the future to subscribe to changes if that
provides performance benefits. Also note that I elected not to change
most calls to `IsIntegrationEnabled()` etc in this PR as there are
hundreds of locations. The follow up PR handles that

Also found a few cases that were incorrectly assuming that these values
cannot change. Marked them with 'TODO: Subscribe to changes in settings'

## Implementation details

- Mostly find and replace to use `CurrentTracerSettings.Settings`
- Occasional extraction of a variable where it makes sense to avoid
repeated access
- Functionally identical currently (where `MutableSettings` is replaced
on `TracerSettings`) but will be a required change once we stop
replacing `TracerManager`.

## Test coverage

Covered by existing tests

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-819

Part of a config stack

- #7522
- #7525
- #7530
- #7532
- #7543 👈
- #7544
andrewlock added a commit that referenced this pull request Oct 22, 2025
…tIntegrationAnalyticsSampleRate()` (#7544)

## Summary of changes

Fix usages of `IsIntegrationEnabled()`, `IsErrorStatusCode()`, and
`GetIntegrationAnalyticsSampleRate()` to use `MutableSettings` instead
of `TracerSettings`

## Reason for change

These functions are dependent on `MutableSettings`, and are exposed
there, so making sure we call the methods there, and remove the
delegation from `TracerSettings` entirely.

## Implementation details

- Find and replace usages
- Remove the old delegating methods

## Test coverage

Just a refactor, so covered by existing tests

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-819

Part of a config stack

- #7522
- #7525
- #7530
- #7532
- #7543
- #7544 👈
- #7695
andrewlock added a commit that referenced this pull request Oct 31, 2025
…ndows (#7721)

## Summary of changes

Enforces that you can't _change_ the `AgentUri` to be a UDS Uri if
you're on Windows

## Reason for change

The trace exporter doesn't work with UDS on Windows, so we have a check
in `TracerSettings` that disables the pipeline if we find this scenario.
However, user's can still _change_ the agent URI at runtime in code (😭).

We currently assume that the data pipeline won't be toggled at runtime
(we _do_ allow for reconfiguring it in general, but not for completely
removing or reintroducing). Changing this to allow the scenario would be
a pain, so instead this PR blocks you from setting a UDS URI in code if
you're on Windows.

The good news is that as far as I can tell, noone does this today, so
while _technically_ it could be considered a breaking change, I think
it's ok.

## Implementation details

- Throw an `ArgumentException` in the Datadog.Trace.Manual library, if
you're on Windows (or .NET FX) and you try to set a UDS agent URI (using
the same "detection" we do in `ExporterSettings`.
- Add a check in the Instrumentation of `Tracer.Configure()` to make
sure it hasn't slipped through. This could happen if a customer was
using an old version of the Datadog.Trace NuGet package with a newer
version of auto instrumentation.

Note that this adds two additional framework references for .NET Core
3.1+, to check if we're on Windows.

## Test coverage

Added an extra step to the manual instrumentation integration test to
confirm we throw

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-819

Part of a config stack

- #7522
- #7525
- #7530
- #7532
- #7543
- #7544
- #7721 👈
- #7722
- #7695
- #7723
- #7724
andrewlock added a commit that referenced this pull request Nov 3, 2025
## Summary of changes

Add a helper for comparing `ReadOnlyDictionary<>` instances

## Reason for change

As part of the config work, we need to detect if tags have changed when
customers do a manual/remote config update. This helper makes it easy

## Implementation details

Added a `SequenceEqual` extension method.

Note that I used `SequenceEqual` because it _already_ exists in
_System.Linq_, but I could see an argument that it's too easy to use the
wrong one, and instead we could use a different name? `IsSameAs(other)`?

Also, I only wrote this for `ReadOnlyDictionary<>` because that's all we
need, it's what we use for all our setting dictionaries, and it will be
(a tiny bit) faster than making it `IDictionary<>`, but happy to change
if people feel strongly.

## Test coverage

Added unit tests

## Other details

https://datadoghq.atlassian.net/browse/LANGPLAT-819

Part of a config stack


- #7522
- #7525
- #7530
- #7532
- #7543
- #7544
- #7721
- #7722 👈
- #7695
- #7723
- #7724

---------

Co-authored-by: Steven Bouwkamp <steven.bouwkamp@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants