Skip to content

Refactor the profiling configuration reading#7303

Merged
andrewlock merged 11 commits into
masterfrom
andrew/refactor-profiling-enabled
Aug 6, 2025
Merged

Refactor the profiling configuration reading#7303
andrewlock merged 11 commits into
masterfrom
andrew/refactor-profiling-enabled

Conversation

@andrewlock

@andrewlock andrewlock commented Jul 30, 2025

Copy link
Copy Markdown
Member

Summary of changes

Refactors how we determine the profiler's current configuration state

Reason for change

Today, the profiler determines if it's enabled or disabled independently of the tracer, in the native code. We then try to mirror that state in the managed code, for several reasons

  • To know whether we need to send app-domain information to the profiler (e.g. service name, env)
  • To know whether we need to send thread-context-change events to the profiler (for CodeHotspots/EndpointProfiling)
  • For telemetry reasons
  • For recording the state in DSM payloads

As part of the hands-off config work, we will calculate whether to enable the profiler based on the full managed config, instead of just using environment variables. However, when managed activation is disabled (for back-compat investigation purposes), we do need to just use env vars, to "mirror" the state that will be calculated by the native continuous profiler, essentially working in the existing "legacy" state.

The refactoring in this PR is intended to lay the groundwork for the future hands-off config work in the profiler, as well as to solve some existing issues with inconsistent/missing telemetry

Implementation details

  • Add a ProfilerState enum to track the profiler as a 3-state enablement which represents its real state, instead of trying to force it as a boolean
  • Use EnvironmentConfigurationSource to record variables read from env in telemetry correctly.
  • Add support for the DD_PROFILER_MANAGED_ACTIVATION_ENABLED which will be used shortly

Test coverage

Added unit tests for the new ProfilerSettings which encapsulates most of the logic

Other details

This PR technically requires support for DD_PROFILER_MANAGED_ACTIVATION_ENABLED has been merged in order to report the correct values. This isn't a big deal, as it will likely be merged soon, but if it isn't, we should tweak the logic in ProfilerSettings so that it's correct. Alternatively, I can split this into two PRs - one that is correct today, and one that is correct only with the profiler PR

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 30, 2025

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

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

@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Jul 30, 2025

Copy link
Copy Markdown

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 (7303) - mean (72ms)  : 70, 73
     .   : milestone, 72,
    master - mean (72ms)  : 70, 73
     .   : milestone, 72,

    section Baseline
    This PR (7303) - mean (68ms)  : 66, 70
     .   : milestone, 68,
    master - mean (69ms)  : 64, 73
     .   : milestone, 69,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (1,049ms)  : 1030, 1067
     .   : milestone, 1049,
    master - mean (1,045ms)  : 1021, 1070
     .   : milestone, 1045,

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

    section Baseline
    This PR (7303) - mean (106ms)  : 103, 108
     .   : milestone, 106,
    master - mean (106ms)  : 103, 109
     .   : milestone, 106,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (727ms)  : 713, 741
     .   : milestone, 727,
    master - mean (731ms)  : 713, 749
     .   : milestone, 731,

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

    section Baseline
    This PR (7303) - mean (94ms)  : 92, 96
     .   : milestone, 94,
    master - mean (93ms)  : 91, 96
     .   : milestone, 93,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (687ms)  : 665, 709
     .   : milestone, 687,
    master - mean (691ms)  : 669, 712
     .   : milestone, 691,

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

    section Baseline
    This PR (7303) - mean (93ms)  : 90, 95
     .   : milestone, 93,
    master - mean (93ms)  : 90, 95
     .   : milestone, 93,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (620ms)  : 609, 632
     .   : milestone, 620,
    master - mean (626ms)  : 614, 638
     .   : milestone, 626,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7303) - mean (192ms)  : 185, 199
     .   : milestone, 192,
    master - mean (192ms)  : 183, 201
     .   : milestone, 192,

    section Baseline
    This PR (7303) - mean (191ms)  : 180, 202
     .   : milestone, 191,
    master - mean (190ms)  : 182, 198
     .   : milestone, 190,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (1,149ms)  : 1118, 1180
     .   : milestone, 1149,
    master - mean (1,145ms)  : 1114, 1176
     .   : milestone, 1145,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7303) - mean (274ms)  : 266, 282
     .   : milestone, 274,
    master - mean (274ms)  : 263, 284
     .   : milestone, 274,

    section Baseline
    This PR (7303) - mean (274ms)  : 263, 286
     .   : milestone, 274,
    master - mean (274ms)  : 262, 286
     .   : milestone, 274,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (916ms)  : 886, 945
     .   : milestone, 916,
    master - mean (922ms)  : 893, 951
     .   : milestone, 922,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7303) - mean (268ms)  : 259, 276
     .   : milestone, 268,
    master - mean (269ms)  : 260, 279
     .   : milestone, 269,

    section Baseline
    This PR (7303) - mean (266ms)  : 256, 276
     .   : milestone, 266,
    master - mean (267ms)  : 259, 275
     .   : milestone, 267,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (902ms)  : 869, 934
     .   : milestone, 902,
    master - mean (912ms)  : 880, 945
     .   : milestone, 912,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Bailout
    This PR (7303) - mean (269ms)  : 260, 278
     .   : milestone, 269,
    master - mean (267ms)  : 258, 276
     .   : milestone, 267,

    section Baseline
    This PR (7303) - mean (266ms)  : 256, 276
     .   : milestone, 266,
    master - mean (267ms)  : 257, 276
     .   : milestone, 267,

    section CallTarget+Inlining+NGEN
    This PR (7303) - mean (813ms)  : 785, 840
     .   : milestone, 813,
    master - mean (812ms)  : 793, 831
     .   : milestone, 812,

Loading

@pr-commenter

pr-commenter Bot commented Jul 30, 2025

Copy link
Copy Markdown

Benchmarks

Benchmarks Report for benchmark platform 🐌

Benchmarks for #7303 compared to master:

  • 2 benchmarks are faster, with geometric mean 1.533
  • 7 benchmarks have fewer allocations
  • 4 benchmarks have more allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 10.8μs 57.1ns 302ns 0 0 0 5.49 KB
master StartStopWithChild netcoreapp3.1 14.5μs 74.5ns 333ns 0 0 0 5.71 KB
master StartStopWithChild net472 21.6μs 122ns 845ns 0.891 0.223 0 6.08 KB
#7303 StartStopWithChild net6.0 10.9μs 51.9ns 214ns 0 0 0 5.49 KB
#7303 StartStopWithChild netcoreapp3.1 13.9μs 67ns 276ns 0 0 0 5.69 KB
#7303 StartStopWithChild net472 21.3μs 98.2ns 367ns 0.871 0.327 0 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 933μs 82.7ns 309ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 1.02ms 549ns 2.13μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 1.22ms 74.9ns 290ns 0 0 0 3.31 KB
#7303 WriteAndFlushEnrichedTraces net6.0 934μs 61.8ns 223ns 0 0 0 2.71 KB
#7303 WriteAndFlushEnrichedTraces netcoreapp3.1 1.02ms 219ns 847ns 0 0 0 2.7 KB
#7303 WriteAndFlushEnrichedTraces net472 1.19ms 78.7ns 294ns 0 0 0 3.31 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 339μs 554ns 2.14μs 0 0 0 198.83 KB
master AllCycleSimpleBody netcoreapp3.1 485μs 1.78μs 6.67μs 0 0 0 206.58 KB
master AllCycleSimpleBody net472 454μs 469ns 1.82μs 37.9 2.23 0 247.06 KB
master AllCycleMoreComplexBody net6.0 341μs 1μs 3.88μs 0 0 0 202.33 KB
master AllCycleMoreComplexBody netcoreapp3.1 520μs 778ns 2.91μs 0 0 0 210 KB
master AllCycleMoreComplexBody net472 458μs 85.2ns 307ns 37.9 2.23 0 250.57 KB
master ObjectExtractorSimpleBody net6.0 332ns 0.95ns 3.68ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 402ns 2.21ns 13.6ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 301ns 0.065ns 0.252ns 0.044 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.3μs 17.2ns 66.4ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.95μs 39.8ns 182ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.72μs 4.75ns 18.4ns 0.571 0 0 3.8 KB
#7303 AllCycleSimpleBody net6.0 337μs 1.26μs 4.7μs 0 0 0 198.49 KB
#7303 AllCycleSimpleBody netcoreapp3.1 484μs 1.46μs 5.65μs 0 0 0 206.2 KB
#7303 AllCycleSimpleBody net472 454μs 108ns 418ns 37.9 2.23 0 246.48 KB
#7303 AllCycleMoreComplexBody net6.0 340μs 1.04μs 4.01μs 0 0 0 202 KB
#7303 AllCycleMoreComplexBody netcoreapp3.1 535μs 377ns 1.46μs 0 0 0 209.62 KB
#7303 AllCycleMoreComplexBody net472 461μs 114ns 428ns 39.4 2.31 0 250.01 KB
#7303 ObjectExtractorSimpleBody net6.0 327ns 1.53ns 6.13ns 0 0 0 280 B
#7303 ObjectExtractorSimpleBody netcoreapp3.1 403ns 2.14ns 10.5ns 0 0 0 272 B
#7303 ObjectExtractorSimpleBody net472 301ns 0.0216ns 0.0748ns 0.044 0 0 281 B
#7303 ObjectExtractorMoreComplexBody net6.0 6.24μs 27.8ns 108ns 0 0 0 3.78 KB
#7303 ObjectExtractorMoreComplexBody netcoreapp3.1 7.79μs 27.1ns 105ns 0 0 0 3.69 KB
#7303 ObjectExtractorMoreComplexBody net472 6.71μs 2.47ns 9.58ns 0.572 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 79μs 237ns 888ns 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 96.7μs 233ns 901ns 0 0 0 32.4 KB
master EncodeArgs net472 109μs 17.2ns 66.5ns 4.92 0 0 32.5 KB
master EncodeLegacyArgs net6.0 150μs 152ns 571ns 0 0 0 2.15 KB
master EncodeLegacyArgs netcoreapp3.1 212μs 156ns 604ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 262μs 101ns 391ns 0 0 0 2.16 KB
#7303 EncodeArgs net6.0 77.9μs 318ns 1.23μs 0 0 0 32.4 KB
#7303 EncodeArgs netcoreapp3.1 97.1μs 266ns 997ns 0 0 0 32.4 KB
#7303 EncodeArgs net472 109μs 19.3ns 74.6ns 4.9 0 0 32.51 KB
#7303 EncodeLegacyArgs net6.0 144μs 41.5ns 161ns 0 0 0 2.15 KB
#7303 EncodeLegacyArgs netcoreapp3.1 199μs 201ns 777ns 0 0 0 2.15 KB
#7303 EncodeLegacyArgs net472 262μs 50.6ns 196ns 0 0 0 2.16 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #7303

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark‑netcoreapp3.1 2.079 857,550.54 412,544.94

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 395μs 143ns 536ns 0 0 0 4.55 KB
master RunWafRealisticBenchmark netcoreapp3.1 804μs 14.3μs 143μs 0 0 0 4.48 KB
master RunWafRealisticBenchmark net472 432μs 107ns 416ns 0 0 0 4.68 KB
master RunWafRealisticBenchmarkWithAttack net6.0 293μs 85.8ns 332ns 0 0 0 2.24 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 304μs 82.6ns 320ns 0 0 0 2.22 KB
master RunWafRealisticBenchmarkWithAttack net472 313μs 73.4ns 284ns 0 0 0 2.29 KB
#7303 RunWafRealisticBenchmark net6.0 395μs 66.6ns 240ns 0 0 0 4.56 KB
#7303 RunWafRealisticBenchmark netcoreapp3.1 413μs 68.7ns 248ns 0 0 0 4.48 KB
#7303 RunWafRealisticBenchmark net472 432μs 77.7ns 301ns 0 0 0 4.66 KB
#7303 RunWafRealisticBenchmarkWithAttack net6.0 289μs 111ns 428ns 0 0 0 2.24 KB
#7303 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 301μs 305ns 1.14μs 0 0 0 2.22 KB
#7303 RunWafRealisticBenchmarkWithAttack net472 312μs 35.4ns 128ns 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.9μs 83ns 311ns 0 0 0 14.52 KB
master SendRequest netcoreapp3.1 70.9μs 108ns 388ns 0 0 0 17.42 KB
master SendRequest net472 0.0116ns 0.00212ns 0.0082ns 0 0 0 0 b
#7303 SendRequest net6.0 60.5μs 68.3ns 246ns 0 0 0 14.52 KB
#7303 SendRequest netcoreapp3.1 71.7μs 75.1ns 271ns 0 0 0 17.42 KB
#7303 SendRequest net472 0.0239ns 0.00126ns 0.00472ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7303

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472 0 b 73 B 73 B
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑netcoreapp3.1 0 b 1 B 1 B
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net472 0 b 47 B 47 B
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net6.0 4 B 7 B 3 B 75.00%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master OriginalCharSlice net6.0 2.02ms 3.2μs 12μs 0 0 0 640.01 KB
master OriginalCharSlice netcoreapp3.1 2.1ms 8.22μs 30.8μs 0 0 0 640 KB
master OriginalCharSlice net472 2.68ms 638ns 2.39μs 100 0 0 641.95 KB
master OptimizedCharSlice net6.0 1.39ms 572ns 2.22μs 0 0 0 4 B
master OptimizedCharSlice netcoreapp3.1 1.72ms 420ns 1.63μs 0 0 0 1 B
master OptimizedCharSlice net472 1.94ms 362ns 1.4μs 0 0 0 0 b
master OptimizedCharSliceWithPool net6.0 795μs 40.8ns 153ns 0 0 0 2 B
master OptimizedCharSliceWithPool netcoreapp3.1 861μs 47.8ns 185ns 0 0 0 0 b
master OptimizedCharSliceWithPool net472 1.16ms 39.8ns 149ns 0 0 0 0 b
#7303 OriginalCharSlice net6.0 1.86ms 4.83μs 18.7μs 0 0 0 640.01 KB
#7303 OriginalCharSlice netcoreapp3.1 2.11ms 4.13μs 14.3μs 0 0 0 640 KB
#7303 OriginalCharSlice net472 2.7ms 2.95μs 11.4μs 100 0 0 641.95 KB
#7303 OptimizedCharSlice net6.0 1.38ms 947ns 3.67μs 0 0 0 7 B
#7303 OptimizedCharSlice netcoreapp3.1 1.75ms 245ns 951ns 0 0 0 1 B
#7303 OptimizedCharSlice net472 1.94ms 613ns 2.37μs 0 0 0 73 B
#7303 OptimizedCharSliceWithPool net6.0 804μs 114ns 440ns 0 0 0 2 B
#7303 OptimizedCharSliceWithPool netcoreapp3.1 832μs 154ns 595ns 0 0 0 1 B
#7303 OptimizedCharSliceWithPool net472 1.14ms 159ns 614ns 0 0 0 47 B
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Faster 🎉 Fewer allocations 🎉

Faster 🎉 in #7303

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 1.131 761,945.62 673,543.75 several?

Fewer allocations 🎉 in #7303

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 56.25 KB 55.65 KB -603 B -1.07%
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 42.44 KB 41.67 KB -769 B -1.81%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 767μs 4.15μs 21.9μs 0 0 0 42.44 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 720μs 3.88μs 22.3μs 0 0 0 41.97 KB
master WriteAndFlushEnrichedTraces net472 946μs 3.49μs 13.5μs 8.33 0 0 56.25 KB
#7303 WriteAndFlushEnrichedTraces net6.0 682μs 3.51μs 17.5μs 0 0 0 41.67 KB
#7303 WriteAndFlushEnrichedTraces netcoreapp3.1 694μs 3.65μs 20.3μs 0 0 0 42.14 KB
#7303 WriteAndFlushEnrichedTraces net472 919μs 3.12μs 11.7μs 4.46 0 0 55.65 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 2.03μs 10.1ns 45.3ns 0 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 2.51μs 8.29ns 32.1ns 0 0 0 1.02 KB
master ExecuteNonQuery net472 2.78μs 4.7ns 18.2ns 0.152 0.0138 0 987 B
#7303 ExecuteNonQuery net6.0 1.92μs 9.4ns 37.6ns 0 0 0 1.02 KB
#7303 ExecuteNonQuery netcoreapp3.1 2.46μs 5.83ns 22.6ns 0 0 0 1.02 KB
#7303 ExecuteNonQuery net472 2.81μs 5.78ns 22.4ns 0.154 0.014 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.77μs 8.69ns 36.9ns 0 0 0 1.03 KB
master CallElasticsearch netcoreapp3.1 2.38μs 5.97ns 23.1ns 0 0 0 1.03 KB
master CallElasticsearch net472 3.48μs 2.04ns 7.9ns 0.156 0 0 1.04 KB
master CallElasticsearchAsync net6.0 1.84μs 8.09ns 31.3ns 0 0 0 1.01 KB
master CallElasticsearchAsync netcoreapp3.1 2.42μs 11.3ns 42.4ns 0 0 0 1.08 KB
master CallElasticsearchAsync net472 3.61μs 2.4ns 9.29ns 0.162 0 0 1.1 KB
#7303 CallElasticsearch net6.0 1.76μs 1.86ns 7.19ns 0 0 0 1.03 KB
#7303 CallElasticsearch netcoreapp3.1 2.4μs 8.62ns 33.4ns 0 0 0 1.03 KB
#7303 CallElasticsearch net472 3.6μs 6.31ns 24.4ns 0.162 0 0 1.04 KB
#7303 CallElasticsearchAsync net6.0 1.8μs 8.73ns 37ns 0 0 0 1.01 KB
#7303 CallElasticsearchAsync netcoreapp3.1 2.5μs 7.37ns 28.6ns 0 0 0 1.08 KB
#7303 CallElasticsearchAsync net472 3.79μs 3.1ns 12ns 0.171 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.86μs 4.66ns 18ns 0 0 0 952 B
master ExecuteAsync netcoreapp3.1 2.32μs 3.76ns 14.1ns 0 0 0 952 B
master ExecuteAsync net472 2.55μs 2.81ns 10.9ns 0.14 0 0 915 B
#7303 ExecuteAsync net6.0 1.87μs 8.9ns 34.5ns 0 0 0 952 B
#7303 ExecuteAsync netcoreapp3.1 2.38μs 12.1ns 55.6ns 0 0 0 952 B
#7303 ExecuteAsync net472 2.5μs 1.24ns 4.79ns 0.138 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 6.88μs 4.65ns 17.4ns 0 0 0 2.36 KB
master SendAsync netcoreapp3.1 8.66μs 5.62ns 21ns 0 0 0 2.9 KB
master SendAsync net472 12.5μs 8.83ns 34.2ns 0.499 0 0 3.18 KB
#7303 SendAsync net6.0 6.68μs 17.7ns 68.4ns 0 0 0 2.36 KB
#7303 SendAsync netcoreapp3.1 8.4μs 17.2ns 66.4ns 0 0 0 2.9 KB
#7303 SendAsync net472 12μs 13.5ns 52.3ns 0.481 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #7303

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 258.79 KB 257.41 KB -1.38 KB -0.53%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 278.53 KB 274.79 KB -3.74 KB -1.34%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 44.39 KB 43.78 KB -616 B -1.39%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 256.52 KB 250.82 KB -5.7 KB -2.22%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 73.73 KB 57.34 KB -16.38 KB -22.22%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 52.6μs 709ns 7.09μs 0 0 0 44.39 KB
master StringConcatBenchmark netcoreapp3.1 54.8μs 685ns 6.81μs 0 0 0 42.82 KB
master StringConcatBenchmark net472 57.2μs 147ns 531ns 0 0 0 73.73 KB
master StringConcatAspectBenchmark net6.0 449μs 2.01μs 7.52μs 0 0 0 256.52 KB
master StringConcatAspectBenchmark netcoreapp3.1 509μs 2.63μs 12.9μs 0 0 0 258.79 KB
master StringConcatAspectBenchmark net472 406μs 1.68μs 6.51μs 0 0 0 278.53 KB
#7303 StringConcatBenchmark net6.0 44.6μs 246ns 1.54μs 0 0 0 43.78 KB
#7303 StringConcatBenchmark netcoreapp3.1 50.5μs 362ns 3.45μs 0 0 0 42.82 KB
#7303 StringConcatBenchmark net472 57.2μs 156ns 564ns 0 0 0 57.34 KB
#7303 StringConcatAspectBenchmark net6.0 453μs 2.13μs 9.99μs 0 0 0 250.82 KB
#7303 StringConcatAspectBenchmark netcoreapp3.1 504μs 2.22μs 8.89μs 0 0 0 257.41 KB
#7303 StringConcatAspectBenchmark net472 407μs 2.22μs 12.8μs 0 0 0 274.79 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.66μs 13.8ns 63.1ns 0 0 0 1.7 KB
master EnrichedLog netcoreapp3.1 3.41μs 16.4ns 71.3ns 0 0 0 1.7 KB
master EnrichedLog net472 3.82μs 3.01ns 11.6ns 0.248 0 0 1.64 KB
#7303 EnrichedLog net6.0 2.53μs 13.7ns 72.3ns 0 0 0 1.71 KB
#7303 EnrichedLog netcoreapp3.1 3.45μs 16.6ns 64.4ns 0 0 0 1.7 KB
#7303 EnrichedLog net472 3.87μs 4.67ns 18.1ns 0.25 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 123μs 72.1ns 260ns 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 128μs 399ns 1.49μs 0 0 0 4.31 KB
master EnrichedLog net472 166μs 111ns 430ns 0 0 0 4.52 KB
#7303 EnrichedLog net6.0 124μs 110ns 427ns 0 0 0 4.31 KB
#7303 EnrichedLog netcoreapp3.1 128μs 129ns 499ns 0 0 0 4.31 KB
#7303 EnrichedLog net472 167μs 139ns 538ns 0 0 0 4.51 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 4.95μs 22.9ns 85.6ns 0 0 0 2.26 KB
master EnrichedLog netcoreapp3.1 6.62μs 14.7ns 57.1ns 0 0 0 2.26 KB
master EnrichedLog net472 7.66μs 7.83ns 30.3ns 0.305 0 0 2.08 KB
#7303 EnrichedLog net6.0 5.01μs 13.2ns 51.2ns 0 0 0 2.26 KB
#7303 EnrichedLog netcoreapp3.1 6.7μs 18.3ns 68.6ns 0 0 0 2.26 KB
#7303 EnrichedLog net472 7.6μs 8.66ns 33.6ns 0.303 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.03μs 8.1ns 31.4ns 0 0 0 1.2 KB
master SendReceive netcoreapp3.1 2.65μs 12.2ns 47.3ns 0 0 0 1.2 KB
master SendReceive net472 3.1μs 6.06ns 23.5ns 0.185 0 0 1.2 KB
#7303 SendReceive net6.0 2.05μs 9.37ns 36.3ns 0 0 0 1.2 KB
#7303 SendReceive netcoreapp3.1 2.66μs 9.85ns 38.1ns 0 0 0 1.2 KB
#7303 SendReceive net472 3.2μs 1.72ns 6.67ns 0.176 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.19μs 7.9ns 30.6ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.39μs 10.7ns 41.6ns 0 0 0 1.63 KB
master EnrichedLog net472 6.49μs 8.61ns 33.4ns 0.321 0 0 2.03 KB
#7303 EnrichedLog net6.0 4.29μs 3.59ns 13.4ns 0 0 0 1.58 KB
#7303 EnrichedLog netcoreapp3.1 5.54μs 11.5ns 44.7ns 0 0 0 1.63 KB
#7303 EnrichedLog net472 6.58μs 7.28ns 28.2ns 0.294 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 754ns 0.199ns 0.744ns 0 0 0 576 B
master StartFinishSpan netcoreapp3.1 957ns 4.93ns 22.1ns 0 0 0 576 B
master StartFinishSpan net472 905ns 0.344ns 1.29ns 0.0905 0 0 578 B
master StartFinishScope net6.0 899ns 3.83ns 14.8ns 0 0 0 696 B
master StartFinishScope netcoreapp3.1 1.13μs 5.28ns 20.4ns 0 0 0 696 B
master StartFinishScope net472 1.06μs 0.342ns 1.33ns 0.101 0 0 658 B
#7303 StartFinishSpan net6.0 758ns 3.59ns 14.4ns 0 0 0 576 B
#7303 StartFinishSpan netcoreapp3.1 945ns 4.76ns 22.3ns 0 0 0 576 B
#7303 StartFinishSpan net472 940ns 0.0712ns 0.257ns 0.0895 0 0 578 B
#7303 StartFinishScope net6.0 908ns 3.98ns 15.4ns 0 0 0 696 B
#7303 StartFinishScope netcoreapp3.1 1.14μs 5.15ns 20.6ns 0 0 0 696 B
#7303 StartFinishScope net472 1.07μs 0.054ns 0.202ns 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μs 4.86ns 19.4ns 0 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1.36μs 6.85ns 32.1ns 0 0 0 697 B
master RunOnMethodBegin net472 1.41μs 1.15ns 4.45ns 0.0981 0 0 658 B
#7303 RunOnMethodBegin net6.0 1.04μs 0.445ns 1.67ns 0 0 0 696 B
#7303 RunOnMethodBegin netcoreapp3.1 1.42μs 4.98ns 19.3ns 0 0 0 696 B
#7303 RunOnMethodBegin net472 1.39μs 0.393ns 1.42ns 0.104 0 0 658 B

Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerSettings.cs Outdated

@chrisnas chrisnas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM except the env var name that should be changed to DD_PROFILER_MANAGED_ACTIVATION_ENABLED instead of DD_PROFILING_MANAGED_ACTIVATION_ENABLED

Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerSettings.cs
Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerSettings.cs
Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerState.cs Outdated
Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerStatus.cs Outdated
Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ConfigurationKeys.cs Outdated
Comment thread tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerSettingsTests.cs Outdated
@andrewlock andrewlock added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:profiler Issues related to the continous-profiler area:telemetry type:refactor labels Jul 31, 2025
@andrewlock
andrewlock marked this pull request as ready for review July 31, 2025 09:48
@andrewlock
andrewlock requested review from a team as code owners July 31, 2025 09:48

@chrisnas chrisnas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerStatus.cs
@andrewlock
andrewlock force-pushed the andrew/refactor-profiling-enabled branch from 7f1458f to 25cd32d Compare July 31, 2025 17:07
@andrewlock
andrewlock force-pushed the andrew/refactor-profiling-enabled branch 4 times, most recently from 06c6e7f to 6ad60b0 Compare August 5, 2025 13:48
@andrewlock
andrewlock force-pushed the andrew/refactor-profiling-enabled branch from 6ad60b0 to e1c85f1 Compare August 6, 2025 09:35
@andrewlock
andrewlock merged commit ed3fd24 into master Aug 6, 2025
157 checks passed
@andrewlock
andrewlock deleted the andrew/refactor-profiling-enabled branch August 6, 2025 11:44
@github-actions github-actions Bot added this to the vNext-v3 milestone Aug 6, 2025
andrewlock added a commit that referenced this pull request Sep 25, 2025
## Summary of changes

Updates the rules around `ProfilerSettings` enablement

## Reason for change

After #7287, we decide whether the profiler is enabled in managed code,
instead of on the native side. However, we got some of the rules wrong.
Specifically, we believed that the profiler should behave different when
`DD_INJECTION_ENABLED` was set, but that's not the case. The profiler
should behave the same in all cases.

## Implementation details

Fixed the implementation to ignore the SSI variable, and updated the
corresponding unit tests

## Test coverage

Updated the tests that were affected

## Other details

The incorrect behaviour was actually introduced in #7303, but it didn't
have a visible impact until #7287
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:profiler Issues related to the continous-profiler area:telemetry 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.

3 participants