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

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



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 96

def self.failure_banner_for(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”.

Returns:

  • (Boolean)


133
134
135
136
137
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 133

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



127
128
129
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 127

def self.render_skipped_reason_file(reason:, suggested:)
  [*reason, *suggested].join(' ')
end

.supported?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 77

def self.supported?
  unsupported_reason.nil?
end

.unsupported_reasonObject



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 81

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