dd-trace-rb
dd-trace-rb copied to clipboard
[PROF-5860] Allow new CPU Profiling 2.0 **alpha** profiler to be enabled
The new Ruby profiler, aka "CPU Profiling 2.0", is considered to be alpha state. We do not recommend turning it on.
But! We actually can turn it on now -- by using DD_PROFILING_FORCE_ENABLE_NEW=true
.
The rest of the pieces have been put into place in previous PRs.
What does this PR do?:
Add a setting that allows choosing between the "old" profiler codepath, and the new "CPU Profiling 2.0" codepath.
Motivation:
Making it possible to test the new profiler.
Additional Notes
This PR sits atop #2208 because without the component in #2208 the profiler would not be able to be turned on. It is otherwise independent from that change.
How to test the change?:
Here's a simple run of the new profiler:
$ DD_TRACE_DEBUG=true DD_PROFILING_ENABLED=true DD_SERVICE=ivoanjo-testing DD_ENV=staging DD_PROFILING_FORCE_ENABLE_NEW=true bundle exec ddtracerb exec ruby -e sleep
I, [2022-08-05T14:40:38.715368 #24783] INFO -- ddtrace: [ddtrace] (dd-trace-rb/lib/datadog/profiling/tasks/setup.rb:47:in `check_if_cpu_time_profiling_is_supported') CPU time profiling skipped because native CPU time is not supported: Feature requires Linux; macOS is not supported. Profiles containing 'Wall time' data will still be reported.
D, [2022-08-05T14:40:38.727312 #24783] DEBUG -- ddtrace: [ddtrace] (dd-trace-rb/lib/datadog/core/workers/async.rb:133:in `start_worker') Starting thread for: #<Datadog::Core::Telemetry::Heartbeat:0x00007f825b982080>
D, [2022-08-05T14:40:38.727510 #24783] DEBUG -- ddtrace: [ddtrace] (dd-trace-rb/lib/datadog/core/configuration/components.rb:371:in `startup!') Profiling started
D, [2022-08-05T14:40:38.727647 #24783] DEBUG -- ddtrace: [ddtrace] (dd-trace-rb/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb:33:in `block in start') Starting thread for: #<Datadog::Profiling::Collectors::CpuAndWallTimeWorker:0x00007f827b91b950>
D, [2022-08-05T14:40:38.727712 #24783] DEBUG -- ddtrace: [ddtrace] (dd-trace-rb/lib/datadog/core/workers/async.rb:133:in `start_worker') Starting thread for: #<Datadog::Profiling::Scheduler:0x00007f826c07bb60>
D, [2022-08-05T14:41:38.735153 #24783] DEBUG -- ddtrace: [ddtrace] (dd-trace-rb/lib/datadog/profiling/stack_recorder.rb:25:in `serialize') Encoded profile covering 2022-08-05T13:40:38Z to 2022-08-05T13:41:38Z
D, [2022-08-05T14:41:40.534027 #24783] DEBUG -- ddtrace: [ddtrace] (dd-trace-rb/lib/datadog/profiling/http_transport.rb:49:in `export') Successfully reported profiling data