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



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 44

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 datadog 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

.render_skipped_reason_file(reason:, suggested:) ⇒ Object

This will be saved in a file to later be presented while operating the gem



75
76
77
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 75

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

.supported?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 26

def self.supported?
  unsupported_reason.nil?
end

.unsupported_reasonObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'ext/datadog_profiling_native_extension/native_extension_helpers.rb', line 30

def self.unsupported_reason
  disabled_via_env? ||
    on_jruby? ||
    on_truffleruby? ||
    on_windows? ||
    on_macos? ||
    on_unknown_os? ||
    on_unsupported_cpu_arch? ||
    expected_to_use_mjit_but_mjit_is_disabled? ||
    libdatadog_not_available? ||
    libdatadog_not_usable?
end