Skip to content

[NO-TICKET] Improve profiling error message when another profiler is present#5375

Merged
ivoanjo merged 5 commits into
masterfrom
ivoanjo/improve-signal-handler-failure
Feb 20, 2026
Merged

[NO-TICKET] Improve profiling error message when another profiler is present#5375
ivoanjo merged 5 commits into
masterfrom
ivoanjo/improve-signal-handler-failure

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Feb 17, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This PR replaces the previously not-very-user-friendly message customers saw when they had a conflicting profiler running:

WARN -- datadog: [datadog] CpuAndWallTimeWorker thread error. Operation: nil Cause: RuntimeError Could not install profiling signal handler (empty_signal_handler): There's a pre-existing SIGPROF signal handler Location: dd-trace-rb/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb:75:in '_native_sampling_loop'
WARN -- datadog: [datadog] Detected issue with profiler (worker component), stopping profiling. See previous log messages for details.

with a much nicer:

WARN -- datadog: [datadog] Profiling was not started as another profiler or gem is already using the SIGPROF signal. Please disable the other profiler to use Datadog profiling.

Motivation:

As I was trying to fix issues that cause the CpuAndWallTimeWorker to fail with a "thread error", this is one of the situations, so we can both improve the message as well as remove it from the list of things that are being reported as thread errors.

Change log entry

Yes. Improve profiling error message when another profiler is present

Additional Notes:

N/A

How to test the change?

I've updated the specs to match. Also, here's my small reproducer that can trigger this easily:

require 'datadog'

Datadog::Profiling::Collectors::CpuAndWallTimeWorker::Testing._native_install_testing_signal_handler

Datadog.configure do |c|
  c.profiling.enabled = true
end

sleep 1

Introduce a new ExistingSignalHandler exception class defined under
the Profiling module (Datadog::Profiling::ExistingSignalHandler) to
provide better error handling when a pre-existing SIGPROF handler is
detected. This allows Ruby code to rescue and handle this specific
failure mode with user-friendly messaging.

Here's the snippet I was using to test it:

```ruby
require 'datadog'

Datadog::Profiling::Collectors::CpuAndWallTimeWorker::Testing._native_install_testing_signal_handler

Datadog.configure do |c|
  c.profiling.enabled = true
end

sleep 1
```
The ubuntu default build of Ruby uses `libruby-3.0.so.3.0` which was breaking
the spec.
@ivoanjo
ivoanjo requested review from a team as code owners February 17, 2026 18:10
@github-actions github-actions Bot added the profiling Involves Datadog profiling label Feb 17, 2026
@ivoanjo

ivoanjo commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

Ooops forgot to update the type signatures, will do it tomorrow

@datadog-official

datadog-official Bot commented Feb 17, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 93.75%
Overall Coverage: 95.10% (+0.01%)

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

@pr-commenter

pr-commenter Bot commented Feb 17, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-02-18 12:54:30

Comparing candidate commit 2f1b386 in PR branch ivoanjo/improve-signal-handler-failure with baseline commit 020f9df in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 44 metrics, 2 unstable metrics.

@github-actions

Copy link
Copy Markdown

Typing analysis

Note: Ignored files are excluded from the next sections.

Untyped methods

This PR introduces 1 partially typed method, and clears 1 partially typed method.

Partially typed methods (+1-1)Introduced:
sig/datadog/profiling.rbs:18
└── def self.try_reading_skipped_reason_file: (?untyped file_api) -> ::String?
Cleared:
sig/datadog/profiling.rbs:14
└── def self.try_reading_skipped_reason_file: (?untyped file_api) -> ::String?

If you believe a method or an attribute is rightfully untyped or partially typed, you can add # untyped:accept on the line before the definition to remove it from the stats.

@ivoanjo

ivoanjo commented Feb 19, 2026

Copy link
Copy Markdown
Member Author

(I'm holding off on merging this until after the next release, to avoid any more delays)

@ivoanjo
ivoanjo merged commit 1f9a18b into master Feb 20, 2026
763 of 765 checks passed
@ivoanjo
ivoanjo deleted the ivoanjo/improve-signal-handler-failure branch February 20, 2026 16:43
@github-actions github-actions Bot added this to the 2.30.0 milestone Feb 20, 2026
@Strech Strech mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Involves Datadog profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants