Module: Datadog::Profiling::NativeExtensionHelpers::Supported
- Defined in:
- ext/datadog_profiling_native_extension/native_extension_helpers.rb
Overview
Used to check if profiler is supported, including user-visible clear messages explaining why their system may not be supported.
Constant Summary collapse
- CONTACT_SUPPORT =
[ 'For help solving this issue, please contact Datadog support at', '<https://docs.datadoghq.com/help/>.', 'You can also check out the Continuous Profiler troubleshooting page at', '<https://dtdg.co/ruby-profiler-troubleshooting>.' ].freeze
- GET_IN_TOUCH =
[ "Get in touch with us if you're interested in profiling your app!" ].freeze
- UPGRADE_RUBY =
[ 'Upgrade to a modern Ruby to enable profiling for your app.' ].freeze
- FAILED_TO_CONFIGURE_LIBDATADOG =
Validation for this check is done in extconf.rb because it relies on mkmf
explain_issue( 'there was a problem in setting up the `libdatadog` dependency.', suggested: CONTACT_SUPPORT, )
- COMPILATION_BROKEN =
Validation for this check is done in extconf.rb because it relies on mkmf
explain_issue( 'compilation of the Ruby VM just-in-time header failed.', 'Your C compiler or Ruby VM just-in-time compiler seem to be broken.', suggested: CONTACT_SUPPORT, )
- PKG_CONFIG_IS_MISSING =
Validation for this check is done in extconf.rb because it relies on mkmf
explain_issue( #+-----------------------------------------------------------------------------+ 'the `pkg-config` system tool is missing.', 'This issue can usually be fixed by installing one of the following:', 'the `pkg-config` package on Homebrew and Debian/Ubuntu-based Linux;', 'the `pkgconf` package on Arch and Alpine-based Linux;', 'the `pkgconf-pkg-config` package on Fedora/Red Hat-based Linux.', '(Tip: When fixing this, ensure `pkg-config` is installed **before**', 'running `bundle install`, and remember to clear any installed gems cache).', suggested: CONTACT_SUPPORT, )
- COMPILER_ATOMIC_MISSING =
Validation for this check is done in extconf.rb because it relies on mkmf
explain_issue( 'your C compiler is missing support for the <stdatomic.h> header.', 'This issue can usually be fixed by upgrading to a later version of your', 'operating system image or compiler.', suggested: CONTACT_SUPPORT, )
Class Method Summary collapse
-
.failure_banner_for(reason:, suggested:, fail_install:) ⇒ Object
This banner will show up in the logs/terminal while compiling the native extension.
-
.pkg_config_missing?(command: $PKGCONFIG) ⇒ Boolean
mkmf sets $PKGCONFIG after the ‘pkg_config` gets used in extconf.rb.
-
.render_skipped_reason_file(reason:, suggested:) ⇒ Object
This will be saved in a file to later be presented while operating the gem.
- .supported? ⇒ Boolean
- .unsupported_reason ⇒ Object
Class Method Details
.failure_banner_for(reason:, suggested:, fail_install:) ⇒ Object
This banner will show up in the logs/terminal while compiling the native extension
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 142 def self.(reason:, suggested:, fail_install:) prettify_lines = proc { |lines| Array(lines).map { |line| "| #{line.ljust(76)} |" }.join("\n") } outcome = if fail_install [ 'Failing installation immediately because the ', "`#{ENV_FAIL_INSTALL_IF_MISSING_EXTENSION}` environment variable is set", 'to `true`.', 'When contacting support, please include the <mkmf.log> file that is shown ', 'below.', ] else [ 'The Datadog Continuous Profiler will not be available,', 'but all other ddtrace features will work fine!', ] end %( +------------------------------------------------------------------------------+ | Could not compile the Datadog Continuous Profiler because | #{prettify_lines.call(reason)} | | #{prettify_lines.call(outcome)} | | #{prettify_lines.call(suggested)} +------------------------------------------------------------------------------+ ) end |
.pkg_config_missing?(command: $PKGCONFIG) ⇒ Boolean
mkmf sets $PKGCONFIG after the ‘pkg_config` gets used in extconf.rb. When `pkg_config` is unsuccessful, we use this helper to decide if we can show more specific error message vs a generic “something went wrong”.
179 180 181 182 183 |
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 179 def self.pkg_config_missing?(command: $PKGCONFIG) # rubocop:disable Style/GlobalVars pkg_config_available = command && xsystem("#{command} --version") pkg_config_available != true end |
.render_skipped_reason_file(reason:, suggested:) ⇒ Object
This will be saved in a file to later be presented while operating the gem
173 174 175 |
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 173 def self.render_skipped_reason_file(reason:, suggested:) [*reason, *suggested].join(' ') end |
.supported? ⇒ Boolean
123 124 125 |
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 123 def self.supported? unsupported_reason.nil? end |
.unsupported_reason ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 127 def self.unsupported_reason disabled_via_env? || on_jruby? || on_truffleruby? || on_windows? || on_macos? || on_unknown_os? || on_unsupported_cpu_arch? || on_unsupported_ruby_version? || expected_to_use_mjit_but_mjit_is_disabled? || libdatadog_not_available? || libdatadog_not_usable? end |