Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Improve error message when ddtrace_profiling_loader fails to load #2957

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Jul 10, 2023

What does this PR do?:

This PR tweaks the error message for when ddtrace_profiling_loader fails to load to suggest to customers that they reinstall ddtrace.

This came out of a customer running into this issue in #2242 (comment)

Here's how it looks now when it fails:

$ DD_PROFILING_ENABLED=true bundle exec ruby -e "require 'datadog/profiling/preload'"
WARN -- ddtrace: [ddtrace] Profiling was requested but is not supported,
profiling disabled: There was an error loading the profiling native extension due to
'LoadError Failed to load the profiling loader extension. To fix this, please remove
and then reinstall ddtrace (Details: cannot load such file --
ddtrace_profiling_loader.2.7.7_x86_64-linux)' at
'load_native_extension.rb:15:in `rescue in <top (required)>''

Motivation:

Suggest the most common fix for this issue instead of leaving customers to wonder about the next steps.

Additional Notes:

Since the ddtrace_profiling_loader is very very simple, it should always be available and be found. When it's not found, on all cases I've seen it's because it hardcodes the current Ruby version it its name, and thus it needs to be rebuilt after upgrading Ruby.

Thus it makes sense to suggest rebuilding it.

(The loader doesn't strictly need to include the Ruby version, but doing so makes it easier to switch Rubies during development, and it acts as a canary for the profiling native extension as well -- if this one fails to load, the native extension will also for the same reason).

How to test the change?:

This issue can be triggered with the example command-line above by not compiling profiler (or running bundle exec rake clean) and then removing any pre-existing profiling extensions
(rm lib/ddtrace_profiling_*).

**What does this PR do?**:

This PR tweaks the error message for when `ddtrace_profiling_loader`
fails to load to suggest to customers that they reinstall ddtrace.

This came out of a customer running into this issue in
<#2242 (comment)>

Here's how it looks now when it fails:

```
$ DD_PROFILING_ENABLED=true bundle exec ruby -e "require 'datadog/profiling/preload'"
WARN -- ddtrace: [ddtrace] Profiling was requested but is not supported,
profiling disabled: There was an error loading the profiling native extension due to
'LoadError Failed to load the profiling loader extension. To fix this, please remove
and then reinstall ddtrace (Details: cannot load such file --
ddtrace_profiling_loader.2.7.7_x86_64-linux)' at
'load_native_extension.rb:15:in `rescue in <top (required)>''
```

**Motivation**:

Suggest the most common fix for this issue instead of leaving
customers to wonder about the next steps.

**Additional Notes**:

Since the `ddtrace_profiling_loader` is very very simple, it should
always be available and be found. When it's not found, on all cases
I've seen it's because it hardcodes the current Ruby version it its
name, and thus it needs to be rebuilt after upgrading Ruby.

Thus it makes sense to suggest rebuilding it.

(The loader doesn't strictly need to include the Ruby version, but
doing so makes it easier to switch Rubies during development, and
it acts as a canary for the profiling native extension as well --
if this one fails to load, the native extension will also for the
same reason).

**How to test the change?**:

This issue can be triggered with the example command-line above by not
compiling profiler (or running `bundle exec rake clean`) and then
removing any pre-existing profiling extensions
(`rm lib/ddtrace_profiling_*`).
@ivoanjo ivoanjo requested a review from a team July 10, 2023 15:01
@github-actions github-actions bot added the profiling Involves Datadog profiling label Jul 10, 2023
@ivoanjo ivoanjo merged commit f168a6f into master Jul 11, 2023
204 checks passed
@ivoanjo ivoanjo deleted the ivoanjo/improve-error-message-loader-failed branch July 11, 2023 08:18
@github-actions github-actions bot added this to the 1.13.0 milestone Jul 11, 2023
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.

None yet

2 participants