Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PROF-5748] Improve error message when pkg-config tool is not installed
In #2068 a customer reported that they were not getting profiling with the message: > Profiling was requested but is not supported, profiling disabled: > Your ddtrace installation is missing support for the Continuous > Profiler because there was a problem in setting up the libddprof > dependency. After investigating this issue (and adding extra tools to debug it, see #2069) it turns out that the customer was missing the `pkg-config` tool. This tool is currently invoked indirectly via Ruby's `mkmf` helper, and is used to configure linking to libddprof/libdatadog. I must admit I was surprised that there's not better error logging in `mkmf` when the `pkg-config` tool is actually missing (vs it being installed but returning an error when being called). Thus, to hopefully avoid other customers running into this issue, I've added a bit of code to detect it, and hopefully present a better error message in that situation. I've also learned that `pkg-config` is "old news" on some Linux distributions, and instead they ship something called `pkgconf` which is a reimplementation of `pkg-config`. Beyond the RSpec tests, this can be triggered for testing by: 1. Changing the `pkg_config` call on extconf.rb ```diff -unless pkg_config('ddprof_ffi_with_rpath') +unless pkg_config('ddprof_ffi_with_rpath_broken') ``` which triggers the generic message (because pkg-config is available but returns an error since the configuration file is not found): ``` +------------------------------------------------------------------------------+ | Could not compile the Datadog Continuous Profiler because | | there was a problem in setting up the `libddprof` dependency. | | | | The Datadog Continuous Profiler will not be available, | | but all other ddtrace features will work fine! | | | | For help solving this issue, please contact Datadog support at | | <https://docs.datadoghq.com/help/>. | +------------------------------------------------------------------------------+ ``` 2. Crippling `pkg_config`: ```bash $ docker-compose run --no-deps --rm tracer-2.1 /bin/bash # doing this inside docker is fine because it doesn't persist $ rm /usr/bin/pkg-config $ bundle exec rake clean compile # ... +------------------------------------------------------------------------------+ | Could not compile the Datadog Continuous Profiler because | | the `pkg-config` system tool is missing. | | This issue can usually be fixed by installing: | | 1. the `pkg-config` package on Homebrew and Debian/Ubuntu-based Linux; | | 2. the `pkgconf` package on Arch and Alpine-based Linux; | | 3. the `pkgconf-pkg-config` package on Fedora/Red Hat-based Linux. | | | | The Datadog Continuous Profiler will not be available, | | but all other ddtrace features will work fine! | | | | For help solving this issue, please contact Datadog support at | | <https://docs.datadoghq.com/help/>. | +------------------------------------------------------------------------------+ ``` Closes #2068
- Loading branch information