datadog 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +87 -2
- data/ext/datadog_profiling_loader/datadog_profiling_loader.c +9 -1
- data/ext/datadog_profiling_loader/extconf.rb +14 -26
- data/ext/datadog_profiling_native_extension/clock_id.h +1 -0
- data/ext/datadog_profiling_native_extension/clock_id_from_pthread.c +1 -2
- data/ext/datadog_profiling_native_extension/clock_id_noop.c +1 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +257 -69
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +53 -28
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +34 -4
- data/ext/datadog_profiling_native_extension/collectors_idle_sampling_helper.c +4 -0
- data/ext/datadog_profiling_native_extension/collectors_stack.c +136 -81
- data/ext/datadog_profiling_native_extension/collectors_stack.h +2 -2
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +661 -48
- data/ext/datadog_profiling_native_extension/collectors_thread_context.h +10 -1
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.c +83 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +53 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +91 -69
- data/ext/datadog_profiling_native_extension/gvl_profiling_helper.c +50 -0
- data/ext/datadog_profiling_native_extension/gvl_profiling_helper.h +75 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.c +54 -12
- data/ext/datadog_profiling_native_extension/heap_recorder.h +3 -1
- data/ext/datadog_profiling_native_extension/helpers.h +6 -17
- data/ext/datadog_profiling_native_extension/http_transport.c +41 -9
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.c +0 -86
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.h +2 -23
- data/ext/datadog_profiling_native_extension/native_extension_helpers.rb +61 -172
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +116 -139
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +20 -11
- data/ext/datadog_profiling_native_extension/profiling.c +1 -3
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +0 -33
- data/ext/datadog_profiling_native_extension/ruby_helpers.h +1 -26
- data/ext/datadog_profiling_native_extension/setup_signal_handler.h +1 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.c +14 -2
- data/ext/datadog_profiling_native_extension/stack_recorder.h +2 -0
- data/ext/datadog_profiling_native_extension/time_helpers.c +0 -15
- data/ext/datadog_profiling_native_extension/time_helpers.h +36 -6
- data/ext/{datadog_profiling_native_extension → libdatadog_api}/crashtracker.c +37 -22
- data/ext/libdatadog_api/datadog_ruby_common.c +83 -0
- data/ext/libdatadog_api/datadog_ruby_common.h +53 -0
- data/ext/libdatadog_api/extconf.rb +108 -0
- data/ext/libdatadog_api/macos_development.md +26 -0
- data/ext/libdatadog_extconf_helpers.rb +130 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +2184 -108
- data/lib/datadog/appsec/assets/waf_rules/strict.json +1430 -2
- data/lib/datadog/appsec/component.rb +29 -8
- data/lib/datadog/appsec/configuration/settings.rb +2 -2
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +1 -0
- data/lib/datadog/appsec/contrib/devise/patcher/rememberable_patch.rb +21 -0
- data/lib/datadog/appsec/contrib/devise/patcher.rb +12 -2
- data/lib/datadog/appsec/contrib/graphql/appsec_trace.rb +35 -0
- data/lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb +109 -0
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +71 -0
- data/lib/datadog/appsec/contrib/graphql/integration.rb +54 -0
- data/lib/datadog/appsec/contrib/graphql/patcher.rb +37 -0
- data/lib/datadog/appsec/contrib/graphql/reactive/multiplex.rb +59 -0
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +3 -6
- data/lib/datadog/appsec/event.rb +1 -1
- data/lib/datadog/appsec/processor/actions.rb +1 -1
- data/lib/datadog/appsec/processor/rule_loader.rb +3 -1
- data/lib/datadog/appsec/processor/rule_merger.rb +33 -15
- data/lib/datadog/appsec/processor.rb +36 -37
- data/lib/datadog/appsec/rate_limiter.rb +25 -40
- data/lib/datadog/appsec/remote.rb +7 -3
- data/lib/datadog/appsec/response.rb +15 -1
- data/lib/datadog/appsec.rb +3 -2
- data/lib/datadog/core/configuration/components.rb +18 -15
- data/lib/datadog/core/configuration/settings.rb +135 -9
- data/lib/datadog/core/crashtracking/agent_base_url.rb +21 -0
- data/lib/datadog/core/crashtracking/component.rb +111 -0
- data/lib/datadog/core/crashtracking/tag_builder.rb +39 -0
- data/lib/datadog/core/diagnostics/environment_logger.rb +8 -11
- data/lib/datadog/core/environment/execution.rb +5 -5
- data/lib/datadog/core/metrics/client.rb +7 -0
- data/lib/datadog/core/rate_limiter.rb +183 -0
- data/lib/datadog/core/remote/client/capabilities.rb +4 -3
- data/lib/datadog/core/remote/component.rb +4 -2
- data/lib/datadog/core/remote/negotiation.rb +4 -4
- data/lib/datadog/core/remote/tie.rb +2 -0
- data/lib/datadog/core/runtime/metrics.rb +1 -1
- data/lib/datadog/core/telemetry/component.rb +51 -2
- data/lib/datadog/core/telemetry/emitter.rb +9 -11
- data/lib/datadog/core/telemetry/event.rb +37 -1
- data/lib/datadog/core/telemetry/ext.rb +1 -0
- data/lib/datadog/core/telemetry/http/adapters/net.rb +10 -12
- data/lib/datadog/core/telemetry/http/ext.rb +3 -0
- data/lib/datadog/core/telemetry/http/transport.rb +38 -9
- data/lib/datadog/core/telemetry/logger.rb +51 -0
- data/lib/datadog/core/telemetry/logging.rb +71 -0
- data/lib/datadog/core/telemetry/request.rb +13 -1
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +102 -0
- data/lib/datadog/core/utils/time.rb +12 -0
- data/lib/datadog/di/code_tracker.rb +168 -0
- data/lib/datadog/di/configuration/settings.rb +163 -0
- data/lib/datadog/di/configuration.rb +11 -0
- data/lib/datadog/di/error.rb +31 -0
- data/lib/datadog/di/extensions.rb +16 -0
- data/lib/datadog/di/probe.rb +133 -0
- data/lib/datadog/di/probe_builder.rb +41 -0
- data/lib/datadog/di/redactor.rb +188 -0
- data/lib/datadog/di/serializer.rb +193 -0
- data/lib/datadog/di.rb +14 -0
- data/lib/datadog/kit/appsec/events.rb +2 -4
- data/lib/datadog/opentelemetry/sdk/propagator.rb +2 -0
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +10 -0
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +23 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +7 -7
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +28 -26
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +11 -13
- data/lib/datadog/profiling/collectors/info.rb +15 -6
- data/lib/datadog/profiling/collectors/thread_context.rb +30 -2
- data/lib/datadog/profiling/component.rb +89 -95
- data/lib/datadog/profiling/exporter.rb +3 -3
- data/lib/datadog/profiling/ext/dir_monkey_patches.rb +3 -3
- data/lib/datadog/profiling/ext.rb +21 -21
- data/lib/datadog/profiling/flush.rb +1 -1
- data/lib/datadog/profiling/http_transport.rb +14 -7
- data/lib/datadog/profiling/load_native_extension.rb +5 -5
- data/lib/datadog/profiling/preload.rb +1 -1
- data/lib/datadog/profiling/profiler.rb +5 -8
- data/lib/datadog/profiling/scheduler.rb +33 -25
- data/lib/datadog/profiling/stack_recorder.rb +3 -0
- data/lib/datadog/profiling/tag_builder.rb +2 -2
- data/lib/datadog/profiling/tasks/exec.rb +5 -5
- data/lib/datadog/profiling/tasks/setup.rb +16 -35
- data/lib/datadog/profiling.rb +4 -5
- data/lib/datadog/single_step_instrument.rb +12 -0
- data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +8 -12
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb +78 -0
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +4 -0
- data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +3 -1
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +4 -1
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +5 -1
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +6 -1
- data/lib/datadog/tracing/contrib/ext.rb +14 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +9 -0
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +19 -0
- data/lib/datadog/tracing/contrib/graphql/patcher.rb +9 -12
- data/lib/datadog/tracing/contrib/graphql/trace_patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/graphql/tracing_patcher.rb +3 -3
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +14 -10
- data/lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb +10 -4
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +18 -15
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +6 -5
- data/lib/datadog/tracing/contrib/httpclient/patcher.rb +1 -14
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/httprb/patcher.rb +1 -14
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +15 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +17 -13
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +13 -6
- data/lib/datadog/tracing/contrib/patcher.rb +2 -1
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +4 -1
- data/lib/datadog/tracing/contrib/presto/patcher.rb +1 -13
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +28 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +5 -1
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +22 -10
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +27 -0
- data/lib/datadog/tracing/contrib/redis/tags.rb +4 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer.rb +4 -0
- data/lib/datadog/tracing/contrib/stripe/request.rb +3 -2
- data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +4 -1
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +14 -16
- data/lib/datadog/tracing/distributed/propagation.rb +7 -0
- data/lib/datadog/tracing/metadata/errors.rb +9 -1
- data/lib/datadog/tracing/metadata/ext.rb +6 -0
- data/lib/datadog/tracing/pipeline/span_filter.rb +2 -2
- data/lib/datadog/tracing/remote.rb +5 -2
- data/lib/datadog/tracing/sampling/matcher.rb +6 -1
- data/lib/datadog/tracing/sampling/rate_sampler.rb +1 -1
- data/lib/datadog/tracing/sampling/rule.rb +2 -0
- data/lib/datadog/tracing/sampling/rule_sampler.rb +9 -5
- data/lib/datadog/tracing/sampling/span/ext.rb +1 -1
- data/lib/datadog/tracing/sampling/span/rule.rb +2 -2
- data/lib/datadog/tracing/span.rb +9 -2
- data/lib/datadog/tracing/span_event.rb +41 -0
- data/lib/datadog/tracing/span_operation.rb +6 -2
- data/lib/datadog/tracing/trace_operation.rb +26 -2
- data/lib/datadog/tracing/tracer.rb +14 -12
- data/lib/datadog/tracing/transport/http/client.rb +1 -0
- data/lib/datadog/tracing/transport/io/client.rb +1 -0
- data/lib/datadog/tracing/transport/serializable_trace.rb +3 -0
- data/lib/datadog/tracing/workers/trace_writer.rb +1 -1
- data/lib/datadog/tracing/workers.rb +1 -1
- data/lib/datadog/version.rb +1 -1
- metadata +46 -11
- data/lib/datadog/profiling/crashtracker.rb +0 -91
- data/lib/datadog/profiling/ext/forking.rb +0 -98
- data/lib/datadog/tracing/sampling/rate_limiter.rb +0 -185
@@ -1,123 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'pathname'
|
5
|
-
|
6
3
|
module Datadog
|
7
4
|
module Profiling
|
8
5
|
# Helpers for extconf.rb
|
9
6
|
module NativeExtensionHelpers
|
10
7
|
# Can be set when customers want to skip compiling the native extension entirely
|
11
|
-
ENV_NO_EXTENSION =
|
8
|
+
ENV_NO_EXTENSION = "DD_PROFILING_NO_EXTENSION"
|
12
9
|
# Can be set to force rubygems to fail gem installation when profiling extension could not be built
|
13
|
-
ENV_FAIL_INSTALL_IF_MISSING_EXTENSION =
|
10
|
+
ENV_FAIL_INSTALL_IF_MISSING_EXTENSION = "DD_PROFILING_FAIL_INSTALL_IF_MISSING_EXTENSION"
|
14
11
|
|
15
12
|
# The MJIT header was introduced on 2.6 and removed on 3.3; for other Rubies we rely on debase-ruby_core_source
|
16
|
-
CAN_USE_MJIT_HEADER = RUBY_VERSION.start_with?(
|
17
|
-
|
18
|
-
LIBDATADOG_VERSION = '~> 10.0.0.1.0'
|
13
|
+
CAN_USE_MJIT_HEADER = RUBY_VERSION.start_with?("2.6", "2.7", "3.0.", "3.1.", "3.2.")
|
19
14
|
|
20
15
|
def self.fail_install_if_missing_extension?
|
21
|
-
ENV[ENV_FAIL_INSTALL_IF_MISSING_EXTENSION].to_s.strip.downcase ==
|
22
|
-
end
|
23
|
-
|
24
|
-
# Used as an workaround for a limitation with how dynamic linking works in environments where the datadog gem and
|
25
|
-
# libdatadog are moved after the extension gets compiled.
|
26
|
-
#
|
27
|
-
# Because the libddpprof native library is installed on a non-standard system path, in order for it to be
|
28
|
-
# found by the system dynamic linker (e.g. what takes care of dlopen(), which is used to load the profiling
|
29
|
-
# native extension), we need to add a "runpath" -- a list of folders to search for libdatadog.
|
30
|
-
#
|
31
|
-
# This runpath gets hardcoded at native library linking time. You can look at it using the `readelf` tool in
|
32
|
-
# Linux: e.g. `readelf -d datadog_profiling_native_extension.2.7.3_x86_64-linux.so`.
|
33
|
-
#
|
34
|
-
# In older versions of the datadog gem, we only set as runpath an absolute path to libdatadog.
|
35
|
-
# (This gets set automatically by the call
|
36
|
-
# to `pkg_config('datadog_profiling_with_rpath')` in `extconf.rb`). This worked fine as long as libdatadog was **NOT**
|
37
|
-
# moved from the folder it was present at datadog gem installation/linking time.
|
38
|
-
#
|
39
|
-
# Unfortunately, environments such as Heroku and AWS Elastic Beanstalk move gems around in the filesystem after
|
40
|
-
# installation. Thus, the profiling native extension could not be loaded in these environments
|
41
|
-
# (see https://github.com/DataDog/dd-trace-rb/issues/2067) because libdatadog could not be found.
|
42
|
-
#
|
43
|
-
# To workaround this issue, this method computes the **relative** path between the folder where the profiling
|
44
|
-
# native extension is going to be installed and the folder where libdatadog is installed, and returns it
|
45
|
-
# to be set as an additional runpath. (Yes, you can set multiple runpath folders to be searched).
|
46
|
-
#
|
47
|
-
# This way, if both gems are moved together (and it turns out that they are in these environments),
|
48
|
-
# the relative path can still be traversed to find libdatadog.
|
49
|
-
#
|
50
|
-
# This is incredibly awful, and it's kinda bizarre how it's not possible to just find these paths at runtime
|
51
|
-
# and set them correctly; rather than needing to set stuff at linking-time and then praying to $deity that
|
52
|
-
# weird moves don't happen.
|
53
|
-
#
|
54
|
-
# As a curiosity, `LD_LIBRARY_PATH` can be used to influence the folders that get searched but **CANNOT BE
|
55
|
-
# SET DYNAMICALLY**, e.g. it needs to be set at the start of the process (Ruby VM) and thus it's not something
|
56
|
-
# we could setup when doing a `require`.
|
57
|
-
#
|
58
|
-
def self.libdatadog_folder_relative_to_native_lib_folder(
|
59
|
-
current_folder: __dir__,
|
60
|
-
libdatadog_pkgconfig_folder: Libdatadog.pkgconfig_folder
|
61
|
-
)
|
62
|
-
return unless libdatadog_pkgconfig_folder
|
63
|
-
|
64
|
-
profiling_native_lib_folder = "#{current_folder}/../../lib/"
|
65
|
-
libdatadog_lib_folder = "#{libdatadog_pkgconfig_folder}/../"
|
66
|
-
|
67
|
-
Pathname.new(libdatadog_lib_folder).relative_path_from(Pathname.new(profiling_native_lib_folder)).to_s
|
68
|
-
end
|
69
|
-
|
70
|
-
# In https://github.com/DataDog/dd-trace-rb/pull/3582 we got a report of a customer for which the native extension
|
71
|
-
# only got installed into the extensions folder.
|
72
|
-
#
|
73
|
-
# But then this fix was not enough to fully get them moving because then they started to see the issue from
|
74
|
-
# https://github.com/DataDog/dd-trace-rb/issues/2067 / https://github.com/DataDog/dd-trace-rb/pull/2125 :
|
75
|
-
#
|
76
|
-
# > Profiling was requested but is not supported, profiling disabled: There was an error loading the profiling
|
77
|
-
# > native extension due to 'RuntimeError Failure to load datadog_profiling_native_extension.3.2.2_x86_64-linux
|
78
|
-
# > due to libdatadog_profiling.so: cannot open shared object file: No such file or directory
|
79
|
-
#
|
80
|
-
# The problem is that when loading the native extension from the extensions directory, the relative rpath we add
|
81
|
-
# with the #libdatadog_folder_relative_to_native_lib_folder helper above is not correct, we need to add a relative
|
82
|
-
# rpath to the extensions directory.
|
83
|
-
#
|
84
|
-
# So how do we find the full path where the native extension is placed?
|
85
|
-
# * From https://github.com/ruby/ruby/blob/83f02d42e0a3c39661dc99c049ab9a70ff227d5b/lib/bundler/runtime.rb#L166
|
86
|
-
# `extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"] + Dir["#{Gem.dir}/bundler/gems/extensions/*/*/*"]`
|
87
|
-
# we get that's in one of two fixed subdirectories of `Gem.dir`
|
88
|
-
# * From https://github.com/ruby/ruby/blob/83f02d42e0a3c39661dc99c049ab9a70ff227d5b/lib/rubygems/basic_specification.rb#L111-L115
|
89
|
-
# we get the structure of the subdirectory (platform/extension_api_version/gem_and_version)
|
90
|
-
#
|
91
|
-
# Thus, `Gem.dir` of `/var/app/current/vendor/bundle/ruby/3.2.0` becomes (for instance)
|
92
|
-
# `/var/app/current/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/datadog-2.0.0/` or
|
93
|
-
# `/var/app/current/vendor/bundle/ruby/3.2.0/bundler/gems/extensions/x86_64-linux/3.2.0/datadog-2.0.0/`
|
94
|
-
#
|
95
|
-
# We then compute the relative path between these folders and the libdatadog folder, and use that as a relative path.
|
96
|
-
def self.libdatadog_folder_relative_to_ruby_extensions_folders(
|
97
|
-
gem_dir: Gem.dir,
|
98
|
-
libdatadog_pkgconfig_folder: Libdatadog.pkgconfig_folder
|
99
|
-
)
|
100
|
-
return unless libdatadog_pkgconfig_folder
|
101
|
-
|
102
|
-
# For the purposes of calculating a folder relative to the other, we don't actually NEED to fill in the
|
103
|
-
# platform, extension_api_version and gem version. We're basically just after how many folders it is deep from
|
104
|
-
# the Gem.dir.
|
105
|
-
expected_ruby_extensions_folders = [
|
106
|
-
"#{gem_dir}/extensions/platform/extension_api_version/datadog_version/",
|
107
|
-
"#{gem_dir}/bundler/gems/extensions/platform/extension_api_version/datadog_version/",
|
108
|
-
]
|
109
|
-
libdatadog_lib_folder = "#{libdatadog_pkgconfig_folder}/../"
|
110
|
-
|
111
|
-
expected_ruby_extensions_folders.map do |folder|
|
112
|
-
Pathname.new(libdatadog_lib_folder).relative_path_from(Pathname.new(folder)).to_s
|
113
|
-
end
|
16
|
+
ENV[ENV_FAIL_INSTALL_IF_MISSING_EXTENSION].to_s.strip.downcase == "true"
|
114
17
|
end
|
115
18
|
|
116
19
|
# Used to check if profiler is supported, including user-visible clear messages explaining why their
|
117
20
|
# system may not be supported.
|
118
21
|
module Supported
|
119
22
|
private_class_method def self.explain_issue(*reason, suggested:)
|
120
|
-
{
|
23
|
+
{reason: reason, suggested: suggested}
|
121
24
|
end
|
122
25
|
|
123
26
|
def self.supported?
|
@@ -143,16 +46,16 @@ module Datadog
|
|
143
46
|
outcome =
|
144
47
|
if fail_install
|
145
48
|
[
|
146
|
-
|
49
|
+
"Failing installation immediately because the ",
|
147
50
|
"`#{ENV_FAIL_INSTALL_IF_MISSING_EXTENSION}` environment variable is set",
|
148
|
-
|
149
|
-
|
150
|
-
|
51
|
+
"to `true`.",
|
52
|
+
"When contacting support, please include the <mkmf.log> file that is shown ",
|
53
|
+
"below.",
|
151
54
|
]
|
152
55
|
else
|
153
56
|
[
|
154
|
-
|
155
|
-
|
57
|
+
"The Datadog Continuous Profiler will not be available,",
|
58
|
+
"but all other datadog features will work fine!",
|
156
59
|
]
|
157
60
|
end
|
158
61
|
|
@@ -170,22 +73,14 @@ module Datadog
|
|
170
73
|
|
171
74
|
# This will be saved in a file to later be presented while operating the gem
|
172
75
|
def self.render_skipped_reason_file(reason:, suggested:)
|
173
|
-
[*reason, *suggested].join(
|
174
|
-
end
|
175
|
-
|
176
|
-
# mkmf sets $PKGCONFIG after the `pkg_config` gets used in extconf.rb. When `pkg_config` is unsuccessful, we use
|
177
|
-
# this helper to decide if we can show more specific error message vs a generic "something went wrong".
|
178
|
-
def self.pkg_config_missing?(command: $PKGCONFIG) # rubocop:disable Style/GlobalVars
|
179
|
-
pkg_config_available = command && xsystem("#{command} --version")
|
180
|
-
|
181
|
-
pkg_config_available != true
|
76
|
+
[*reason, *suggested].join(" ")
|
182
77
|
end
|
183
78
|
|
184
79
|
CONTACT_SUPPORT = [
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
80
|
+
"For help solving this issue, please contact Datadog support at",
|
81
|
+
"<https://docs.datadoghq.com/help/>.",
|
82
|
+
"You can also check out the Continuous Profiler troubleshooting page at",
|
83
|
+
"<https://dtdg.co/ruby-profiler-troubleshooting>."
|
189
84
|
].freeze
|
190
85
|
|
191
86
|
GET_IN_TOUCH = [
|
@@ -193,83 +88,83 @@ module Datadog
|
|
193
88
|
].freeze
|
194
89
|
|
195
90
|
UPGRADE_RUBY = [
|
196
|
-
|
91
|
+
"Upgrade to a modern Ruby to enable profiling for your app."
|
197
92
|
].freeze
|
198
93
|
|
199
94
|
# Validation for this check is done in extconf.rb because it relies on mkmf
|
200
95
|
FAILED_TO_CONFIGURE_LIBDATADOG = explain_issue(
|
201
|
-
|
96
|
+
"there was a problem in setting up the `libdatadog` dependency.",
|
202
97
|
suggested: CONTACT_SUPPORT,
|
203
98
|
)
|
204
99
|
|
205
100
|
# Validation for this check is done in extconf.rb because it relies on mkmf
|
206
101
|
COMPILATION_BROKEN = explain_issue(
|
207
|
-
|
208
|
-
|
102
|
+
"compilation of the Ruby VM just-in-time header failed.",
|
103
|
+
"Your C compiler or Ruby VM just-in-time compiler seem to be broken.",
|
209
104
|
suggested: CONTACT_SUPPORT,
|
210
105
|
)
|
211
106
|
|
212
107
|
# Validation for this check is done in extconf.rb because it relies on mkmf
|
213
108
|
PKG_CONFIG_IS_MISSING = explain_issue(
|
214
109
|
# ----------------------------------------------------------------------------+
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
110
|
+
"the `pkg-config` system tool is missing.",
|
111
|
+
"This issue can usually be fixed by installing one of the following:",
|
112
|
+
"the `pkg-config` package on Homebrew and Debian/Ubuntu-based Linux;",
|
113
|
+
"the `pkgconf` package on Arch and Alpine-based Linux;",
|
114
|
+
"the `pkgconf-pkg-config` package on Fedora/Red Hat-based Linux.",
|
115
|
+
"(Tip: When fixing this, ensure `pkg-config` is installed **before**",
|
116
|
+
"running `bundle install`, and remember to clear any installed gems cache).",
|
222
117
|
suggested: CONTACT_SUPPORT,
|
223
118
|
)
|
224
119
|
|
225
120
|
# Validation for this check is done in extconf.rb because it relies on mkmf
|
226
121
|
COMPILER_ATOMIC_MISSING = explain_issue(
|
227
|
-
|
228
|
-
|
229
|
-
|
122
|
+
"your C compiler is missing support for the <stdatomic.h> header.",
|
123
|
+
"This issue can usually be fixed by upgrading to a later version of your",
|
124
|
+
"operating system image or compiler.",
|
230
125
|
suggested: CONTACT_SUPPORT,
|
231
126
|
)
|
232
127
|
|
233
128
|
private_class_method def self.disabled_via_env?
|
234
129
|
report_disabled = [
|
235
|
-
|
236
|
-
|
130
|
+
"If you needed to use this, please tell us why on",
|
131
|
+
"<https://github.com/DataDog/dd-trace-rb/issues/new> so we can fix it :)",
|
237
132
|
].freeze
|
238
133
|
|
239
134
|
disabled_via_env = explain_issue(
|
240
|
-
|
241
|
-
|
135
|
+
"the `DD_PROFILING_NO_EXTENSION` environment variable is/was set to",
|
136
|
+
"`true` during installation.",
|
242
137
|
suggested: report_disabled,
|
243
138
|
)
|
244
139
|
|
245
|
-
return unless ENV[ENV_NO_EXTENSION].to_s.strip.downcase ==
|
140
|
+
return unless ENV[ENV_NO_EXTENSION].to_s.strip.downcase == "true"
|
246
141
|
|
247
142
|
disabled_via_env
|
248
143
|
end
|
249
144
|
|
250
145
|
private_class_method def self.on_jruby?
|
251
146
|
jruby_not_supported = explain_issue(
|
252
|
-
|
147
|
+
"JRuby is not supported by the Datadog Continuous Profiler.",
|
253
148
|
suggested: GET_IN_TOUCH,
|
254
149
|
)
|
255
150
|
|
256
|
-
jruby_not_supported if RUBY_ENGINE ==
|
151
|
+
jruby_not_supported if RUBY_ENGINE == "jruby"
|
257
152
|
end
|
258
153
|
|
259
154
|
private_class_method def self.on_truffleruby?
|
260
155
|
truffleruby_not_supported = explain_issue(
|
261
|
-
|
156
|
+
"TruffleRuby is not supported by the datadog gem.",
|
262
157
|
suggested: GET_IN_TOUCH,
|
263
158
|
)
|
264
159
|
|
265
|
-
truffleruby_not_supported if RUBY_ENGINE ==
|
160
|
+
truffleruby_not_supported if RUBY_ENGINE == "truffleruby"
|
266
161
|
end
|
267
162
|
|
268
163
|
# See https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#microsoft-windows-support for current
|
269
164
|
# state of Windows support in the datadog gem.
|
270
165
|
private_class_method def self.on_windows?
|
271
166
|
windows_not_supported = explain_issue(
|
272
|
-
|
167
|
+
"Microsoft Windows is not supported by the Datadog Continuous Profiler.",
|
273
168
|
suggested: GET_IN_TOUCH,
|
274
169
|
)
|
275
170
|
|
@@ -278,72 +173,66 @@ module Datadog
|
|
278
173
|
|
279
174
|
private_class_method def self.on_macos?
|
280
175
|
macos_not_supported = explain_issue(
|
281
|
-
|
176
|
+
"macOS is currently not supported by the Datadog Continuous Profiler.",
|
282
177
|
suggested: GET_IN_TOUCH,
|
283
178
|
)
|
284
179
|
# For development only; not supported otherwise
|
285
|
-
macos_testing_override = ENV[
|
180
|
+
macos_testing_override = ENV["DD_PROFILING_MACOS_TESTING"] == "true"
|
286
181
|
|
287
|
-
macos_not_supported if RUBY_PLATFORM.include?(
|
182
|
+
macos_not_supported if RUBY_PLATFORM.include?("darwin") && !macos_testing_override
|
288
183
|
end
|
289
184
|
|
290
185
|
private_class_method def self.on_unknown_os?
|
291
186
|
unknown_os_not_supported = explain_issue(
|
292
|
-
|
187
|
+
"your operating system is not supported by the Datadog Continuous Profiler.",
|
293
188
|
suggested: GET_IN_TOUCH,
|
294
189
|
)
|
295
190
|
|
296
|
-
unknown_os_not_supported unless RUBY_PLATFORM.include?(
|
191
|
+
unknown_os_not_supported unless RUBY_PLATFORM.include?("darwin") || RUBY_PLATFORM.include?("linux")
|
297
192
|
end
|
298
193
|
|
299
194
|
private_class_method def self.on_unsupported_cpu_arch?
|
300
195
|
architecture_not_supported = explain_issue(
|
301
|
-
|
196
|
+
"your CPU architecture is not supported by the Datadog Continuous Profiler.",
|
302
197
|
suggested: GET_IN_TOUCH,
|
303
198
|
)
|
304
199
|
|
305
|
-
architecture_not_supported unless RUBY_PLATFORM.start_with?(
|
200
|
+
architecture_not_supported unless RUBY_PLATFORM.start_with?("x86_64", "aarch64", "arm64")
|
306
201
|
end
|
307
202
|
|
308
203
|
# On some Rubies, we require the mjit header to be present. If Ruby was installed without MJIT support, we also skip
|
309
204
|
# building the extension.
|
310
205
|
private_class_method def self.expected_to_use_mjit_but_mjit_is_disabled?
|
311
206
|
ruby_without_mjit = explain_issue(
|
312
|
-
|
313
|
-
|
314
|
-
|
207
|
+
"your Ruby has been compiled without JIT support (--disable-jit-support).",
|
208
|
+
"The profiling native extension requires a Ruby compiled with JIT support,",
|
209
|
+
"even if the JIT is not in use by the application itself.",
|
315
210
|
suggested: CONTACT_SUPPORT,
|
316
211
|
)
|
317
212
|
|
318
|
-
ruby_without_mjit if CAN_USE_MJIT_HEADER && RbConfig::CONFIG[
|
213
|
+
ruby_without_mjit if CAN_USE_MJIT_HEADER && RbConfig::CONFIG["MJIT_SUPPORT"] != "yes"
|
319
214
|
end
|
320
215
|
|
321
216
|
private_class_method def self.libdatadog_not_available?
|
322
|
-
|
323
|
-
gem 'libdatadog', LIBDATADOG_VERSION
|
324
|
-
require 'libdatadog'
|
325
|
-
nil
|
326
|
-
# rubocop:disable Lint/RescueException
|
327
|
-
rescue Exception => e
|
217
|
+
Datadog::LibdatadogExtconfHelpers.try_loading_libdatadog do |exception|
|
328
218
|
explain_issue(
|
329
|
-
|
330
|
-
|
331
|
-
*
|
332
|
-
*Array(
|
333
|
-
|
219
|
+
"there was an exception during loading of the `libdatadog` gem:",
|
220
|
+
exception.class.name,
|
221
|
+
*exception.message.split("\n"),
|
222
|
+
*Array(exception.backtrace),
|
223
|
+
".",
|
334
224
|
suggested: CONTACT_SUPPORT,
|
335
225
|
)
|
336
226
|
end
|
337
|
-
# rubocop:enable Lint/RescueException
|
338
227
|
end
|
339
228
|
|
340
229
|
private_class_method def self.libdatadog_not_usable?
|
341
230
|
no_binaries_for_current_platform = explain_issue(
|
342
|
-
|
343
|
-
|
231
|
+
"the `libdatadog` gem installed on your system is missing binaries for your",
|
232
|
+
"platform variant.",
|
344
233
|
"(Your platform: `#{Libdatadog.current_platform}`)",
|
345
|
-
|
346
|
-
"`#{Libdatadog.available_binaries.join(
|
234
|
+
"(Available binaries:",
|
235
|
+
"`#{Libdatadog.available_binaries.join("`, `")}`)",
|
347
236
|
suggested: CONTACT_SUPPORT,
|
348
237
|
)
|
349
238
|
|