datadog 2.16.0 → 2.18.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 +72 -1
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +12 -46
- data/ext/datadog_profiling_native_extension/collectors_stack.c +227 -49
- data/ext/datadog_profiling_native_extension/collectors_stack.h +19 -3
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +63 -12
- data/ext/datadog_profiling_native_extension/collectors_thread_context.h +1 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.c +22 -12
- data/ext/datadog_profiling_native_extension/encoded_profile.h +1 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +7 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.c +239 -363
- data/ext/datadog_profiling_native_extension/heap_recorder.h +4 -6
- data/ext/datadog_profiling_native_extension/http_transport.c +45 -72
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.c +22 -0
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.h +8 -5
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +1 -0
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +6 -3
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +1 -13
- data/ext/datadog_profiling_native_extension/ruby_helpers.h +2 -10
- data/ext/datadog_profiling_native_extension/stack_recorder.c +156 -60
- data/ext/libdatadog_api/crashtracker.c +10 -3
- data/ext/libdatadog_api/extconf.rb +2 -2
- data/ext/libdatadog_api/library_config.c +54 -12
- data/ext/libdatadog_api/library_config.h +6 -0
- data/ext/libdatadog_api/macos_development.md +3 -3
- data/ext/libdatadog_api/process_discovery.c +2 -7
- data/ext/libdatadog_extconf_helpers.rb +2 -2
- data/lib/datadog/appsec/api_security/lru_cache.rb +56 -0
- data/lib/datadog/appsec/api_security/route_extractor.rb +65 -0
- data/lib/datadog/appsec/api_security/sampler.rb +59 -0
- data/lib/datadog/appsec/api_security.rb +23 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +257 -85
- data/lib/datadog/appsec/assets/waf_rules/strict.json +10 -78
- data/lib/datadog/appsec/component.rb +30 -54
- data/lib/datadog/appsec/configuration/settings.rb +60 -2
- data/lib/datadog/appsec/context.rb +6 -6
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +27 -16
- data/lib/datadog/appsec/processor/rule_loader.rb +5 -6
- data/lib/datadog/appsec/remote.rb +15 -55
- data/lib/datadog/appsec/security_engine/engine.rb +194 -0
- data/lib/datadog/appsec/security_engine/runner.rb +10 -11
- data/lib/datadog/appsec.rb +4 -7
- data/lib/datadog/core/buffer/random.rb +18 -2
- data/lib/datadog/core/configuration/agent_settings.rb +52 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +4 -46
- data/lib/datadog/core/configuration/components.rb +31 -24
- data/lib/datadog/core/configuration/components_state.rb +23 -0
- data/lib/datadog/core/configuration/option.rb +27 -27
- data/lib/datadog/core/configuration/option_definition.rb +4 -4
- data/lib/datadog/core/configuration/options.rb +1 -1
- data/lib/datadog/core/configuration/settings.rb +32 -20
- data/lib/datadog/core/configuration/stable_config.rb +1 -2
- data/lib/datadog/core/configuration.rb +16 -16
- data/lib/datadog/core/crashtracking/component.rb +2 -1
- data/lib/datadog/core/crashtracking/tag_builder.rb +4 -22
- data/lib/datadog/core/encoding.rb +1 -1
- data/lib/datadog/core/environment/cgroup.rb +10 -12
- data/lib/datadog/core/environment/container.rb +38 -40
- data/lib/datadog/core/environment/ext.rb +6 -6
- data/lib/datadog/core/environment/identity.rb +3 -3
- data/lib/datadog/core/environment/platform.rb +3 -3
- data/lib/datadog/core/error.rb +11 -9
- data/lib/datadog/core/logger.rb +2 -2
- data/lib/datadog/core/metrics/client.rb +12 -14
- data/lib/datadog/core/metrics/logging.rb +5 -5
- data/lib/datadog/core/process_discovery/tracer_memfd.rb +15 -0
- data/lib/datadog/core/process_discovery.rb +5 -1
- data/lib/datadog/core/rate_limiter.rb +4 -2
- data/lib/datadog/core/remote/client.rb +32 -31
- data/lib/datadog/core/remote/component.rb +3 -3
- data/lib/datadog/core/remote/configuration/digest.rb +7 -7
- data/lib/datadog/core/remote/configuration/path.rb +1 -1
- data/lib/datadog/core/remote/configuration/repository.rb +12 -0
- data/lib/datadog/core/remote/transport/http/client.rb +1 -1
- data/lib/datadog/core/remote/transport/http/config.rb +21 -5
- data/lib/datadog/core/remote/transport/http/negotiation.rb +1 -1
- data/lib/datadog/core/runtime/metrics.rb +3 -3
- data/lib/datadog/core/tag_builder.rb +56 -0
- data/lib/datadog/core/telemetry/component.rb +39 -24
- data/lib/datadog/core/telemetry/emitter.rb +7 -1
- data/lib/datadog/core/telemetry/event/app_client_configuration_change.rb +66 -0
- data/lib/datadog/core/telemetry/event/app_closing.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_dependencies_loaded.rb +33 -0
- data/lib/datadog/core/telemetry/event/app_heartbeat.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_integrations_change.rb +58 -0
- data/lib/datadog/core/telemetry/event/app_started.rb +269 -0
- data/lib/datadog/core/telemetry/event/base.rb +40 -0
- data/lib/datadog/core/telemetry/event/distributions.rb +18 -0
- data/lib/datadog/core/telemetry/event/generate_metrics.rb +43 -0
- data/lib/datadog/core/telemetry/event/log.rb +76 -0
- data/lib/datadog/core/telemetry/event/message_batch.rb +42 -0
- data/lib/datadog/core/telemetry/event/synth_app_client_configuration_change.rb +43 -0
- data/lib/datadog/core/telemetry/event.rb +17 -475
- data/lib/datadog/core/telemetry/logger.rb +5 -4
- data/lib/datadog/core/telemetry/logging.rb +11 -5
- data/lib/datadog/core/telemetry/metric.rb +3 -3
- data/lib/datadog/core/telemetry/transport/http/telemetry.rb +2 -2
- data/lib/datadog/core/telemetry/transport/telemetry.rb +0 -1
- data/lib/datadog/core/telemetry/worker.rb +48 -27
- data/lib/datadog/core/transport/http/adapters/net.rb +17 -2
- data/lib/datadog/core/transport/http/adapters/test.rb +2 -1
- data/lib/datadog/core/transport/http/builder.rb +14 -14
- data/lib/datadog/core/transport/http/env.rb +8 -0
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +6 -6
- data/lib/datadog/core/utils/duration.rb +32 -32
- data/lib/datadog/core/utils/forking.rb +2 -2
- data/lib/datadog/core/utils/network.rb +6 -6
- data/lib/datadog/core/utils/only_once_successful.rb +16 -5
- data/lib/datadog/core/utils/time.rb +10 -2
- data/lib/datadog/core/utils/truncation.rb +21 -0
- data/lib/datadog/core/utils.rb +7 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +1 -1
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +8 -8
- data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +7 -7
- data/lib/datadog/core/worker.rb +1 -1
- data/lib/datadog/core/workers/async.rb +9 -10
- data/lib/datadog/di/instrumenter.rb +52 -2
- data/lib/datadog/di/probe_notification_builder.rb +31 -41
- data/lib/datadog/di/probe_notifier_worker.rb +9 -1
- data/lib/datadog/di/serializer.rb +6 -2
- data/lib/datadog/di/transport/http/input.rb +10 -0
- data/lib/datadog/di/transport/input.rb +10 -2
- data/lib/datadog/error_tracking/component.rb +2 -2
- data/lib/datadog/profiling/collectors/code_provenance.rb +18 -9
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +4 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +16 -1
- data/lib/datadog/profiling/component.rb +7 -9
- data/lib/datadog/profiling/ext.rb +0 -13
- data/lib/datadog/profiling/flush.rb +1 -1
- data/lib/datadog/profiling/http_transport.rb +3 -8
- data/lib/datadog/profiling/profiler.rb +2 -0
- data/lib/datadog/profiling/scheduler.rb +10 -2
- data/lib/datadog/profiling/stack_recorder.rb +5 -5
- data/lib/datadog/profiling/tag_builder.rb +5 -41
- data/lib/datadog/profiling/tasks/setup.rb +2 -0
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +15 -0
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb +19 -12
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +4 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +33 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -4
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +10 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +5 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +1 -5
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +1 -5
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +1 -5
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +4 -2
- data/lib/datadog/tracing/contrib/patcher.rb +5 -2
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +5 -2
- data/lib/datadog/tracing/contrib/support.rb +28 -0
- data/lib/datadog/tracing/metadata/errors.rb +4 -4
- data/lib/datadog/tracing/sync_writer.rb +1 -1
- data/lib/datadog/tracing/trace_operation.rb +12 -4
- data/lib/datadog/tracing/tracer.rb +6 -2
- data/lib/datadog/version.rb +1 -1
- metadata +31 -12
- data/lib/datadog/appsec/assets/waf_rules/processors.json +0 -321
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +0 -1023
- data/lib/datadog/appsec/processor/rule_merger.rb +0 -171
- data/lib/datadog/appsec/processor.rb +0 -107
@@ -22,7 +22,7 @@ module Datadog
|
|
22
22
|
# Represents an Option precedence level.
|
23
23
|
# Each precedence has a `numeric` value; higher values means higher precedence.
|
24
24
|
# `name` is for inspection purposes only.
|
25
|
-
Value = Struct.new(:numeric, :name) do
|
25
|
+
Value = Struct.new(:numeric, :name, :origin) do
|
26
26
|
include Comparable
|
27
27
|
|
28
28
|
def <=>(other)
|
@@ -33,22 +33,22 @@ module Datadog
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Remote configuration provided through the Datadog app.
|
36
|
-
REMOTE_CONFIGURATION = Value.new(5, :remote_configuration).freeze
|
36
|
+
REMOTE_CONFIGURATION = Value.new(5, :remote_configuration, 'remote_config').freeze
|
37
37
|
|
38
38
|
# Configuration provided in Ruby code, in this same process
|
39
|
-
PROGRAMMATIC = Value.new(4, :programmatic).freeze
|
39
|
+
PROGRAMMATIC = Value.new(4, :programmatic, 'code').freeze
|
40
40
|
|
41
41
|
# Configuration provided by fleet managed stable config
|
42
|
-
FLEET_STABLE = Value.new(3, :fleet_stable).freeze
|
42
|
+
FLEET_STABLE = Value.new(3, :fleet_stable, 'fleet_stable_config').freeze
|
43
43
|
|
44
44
|
# Configuration provided via environment variable
|
45
|
-
ENVIRONMENT = Value.new(2, :environment).freeze
|
45
|
+
ENVIRONMENT = Value.new(2, :environment, 'env_var').freeze
|
46
46
|
|
47
47
|
# Configuration provided by local stable config file
|
48
|
-
LOCAL_STABLE = Value.new(1, :local_stable).freeze
|
48
|
+
LOCAL_STABLE = Value.new(1, :local_stable, 'local_stable_config').freeze
|
49
49
|
|
50
50
|
# Configuration that comes from default values
|
51
|
-
DEFAULT = Value.new(0, :default).freeze
|
51
|
+
DEFAULT = Value.new(0, :default, 'default').freeze
|
52
52
|
|
53
53
|
# All precedences, sorted from highest to lowest
|
54
54
|
LIST = [REMOTE_CONFIGURATION, PROGRAMMATIC, FLEET_STABLE, ENVIRONMENT, LOCAL_STABLE, DEFAULT].sort.reverse.freeze
|
@@ -142,14 +142,14 @@ module Datadog
|
|
142
142
|
|
143
143
|
def reset
|
144
144
|
@value = if definition.resetter
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
145
|
+
# Don't change @is_set to false; custom resetters are
|
146
|
+
# responsible for changing @value back to a good state.
|
147
|
+
# Setting @is_set = false would cause a default to be applied.
|
148
|
+
context_exec(@value, &definition.resetter)
|
149
|
+
else
|
150
|
+
@is_set = false
|
151
|
+
nil
|
152
|
+
end
|
153
153
|
|
154
154
|
# Reset back to the lowest precedence, to allow all `set`s to succeed right after a reset.
|
155
155
|
@precedence_set = Precedence::DEFAULT
|
@@ -227,20 +227,20 @@ module Datadog
|
|
227
227
|
|
228
228
|
unless valid_type
|
229
229
|
raise_error = if @definition.type_options[:nilable]
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
230
|
+
!value.is_a?(NilClass)
|
231
|
+
else
|
232
|
+
true
|
233
|
+
end
|
234
234
|
end
|
235
235
|
|
236
236
|
if raise_error
|
237
237
|
error_msg = if @definition.type_options[:nilable]
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
238
|
+
"The setting `#{@definition.name}` inside your app's `Datadog.configure` block expects a " \
|
239
|
+
"#{@definition.type} or `nil`, but a `#{value.class}` was provided (#{value.inspect})." \
|
240
|
+
else
|
241
|
+
"The setting `#{@definition.name}` inside your app's `Datadog.configure` block expects a " \
|
242
|
+
"#{@definition.type}, but a `#{value.class}` was provided (#{value.inspect})." \
|
243
|
+
end
|
244
244
|
|
245
245
|
error_msg = "#{error_msg} Please update your `configure` block. "
|
246
246
|
|
@@ -309,7 +309,7 @@ module Datadog
|
|
309
309
|
end
|
310
310
|
|
311
311
|
def set_customer_stable_config_value
|
312
|
-
customer_config = StableConfig.configuration
|
312
|
+
customer_config = StableConfig.configuration.dig(:local, :config)
|
313
313
|
return if customer_config.nil?
|
314
314
|
|
315
315
|
value, resolved_env = get_value_and_resolved_env_from(customer_config, source: 'local stable config')
|
@@ -317,7 +317,7 @@ module Datadog
|
|
317
317
|
end
|
318
318
|
|
319
319
|
def set_fleet_stable_config_value
|
320
|
-
fleet_config = StableConfig.configuration
|
320
|
+
fleet_config = StableConfig.configuration.dig(:fleet, :config)
|
321
321
|
return if fleet_config.nil?
|
322
322
|
|
323
323
|
value, resolved_env = get_value_and_resolved_env_from(fleet_config, source: 'fleet stable config')
|
@@ -71,11 +71,11 @@ module Datadog
|
|
71
71
|
validate_options!
|
72
72
|
end
|
73
73
|
|
74
|
-
def env(value)
|
74
|
+
def env(value) # standard:disable Style/TrivialAccessors
|
75
75
|
@env = value
|
76
76
|
end
|
77
77
|
|
78
|
-
def deprecated_env(value)
|
78
|
+
def deprecated_env(value) # standard:disable Style/TrivialAccessors
|
79
79
|
@deprecated_env = value
|
80
80
|
end
|
81
81
|
|
@@ -111,7 +111,7 @@ module Datadog
|
|
111
111
|
|
112
112
|
def type(value, nilable: false)
|
113
113
|
@type = value
|
114
|
-
@type_options = {
|
114
|
+
@type_options = {nilable: nilable}
|
115
115
|
|
116
116
|
value
|
117
117
|
end
|
@@ -156,7 +156,7 @@ module Datadog
|
|
156
156
|
if !@default.nil? && @default_proc
|
157
157
|
raise InvalidOptionError,
|
158
158
|
'Using `default` and `default_proc` is not allowed. Please use one or the other.' \
|
159
|
-
'If you want to store a block as the default value use `default_proc`'\
|
159
|
+
'If you want to store a block as the default value use `default_proc`' \
|
160
160
|
' otherwise use `default`'
|
161
161
|
end
|
162
162
|
end
|
@@ -18,7 +18,7 @@ module Datadog
|
|
18
18
|
module ClassMethods
|
19
19
|
def options
|
20
20
|
# Allows for class inheritance of option definitions
|
21
|
-
@options ||= superclass <= Options ? superclass.options.dup : {}
|
21
|
+
@options ||= (superclass <= Options) ? superclass.options.dup : {}
|
22
22
|
end
|
23
23
|
|
24
24
|
protected
|
@@ -18,7 +18,7 @@ module Datadog
|
|
18
18
|
module Configuration
|
19
19
|
# Global configuration settings for the Datadog library.
|
20
20
|
# @public_api
|
21
|
-
#
|
21
|
+
# standard:disable Metrics/BlockLength
|
22
22
|
class Settings
|
23
23
|
include Base
|
24
24
|
|
@@ -123,7 +123,7 @@ module Datadog
|
|
123
123
|
# @return [Boolean]
|
124
124
|
option :debug do |o|
|
125
125
|
o.env [Datadog::Core::Configuration::Ext::Diagnostics::ENV_DEBUG_ENABLED,
|
126
|
-
|
126
|
+
Datadog::Core::Configuration::Ext::Diagnostics::ENV_OTEL_LOG_LEVEL]
|
127
127
|
o.default false
|
128
128
|
o.type :bool
|
129
129
|
o.env_parser do |value|
|
@@ -137,7 +137,7 @@ module Datadog
|
|
137
137
|
o.after_set do |enabled|
|
138
138
|
# Enable rich debug print statements.
|
139
139
|
# We do not need to unnecessarily load 'pp' unless in debugging mode.
|
140
|
-
require 'pp' if enabled
|
140
|
+
require 'pp' if enabled # standard:disable Lint/RedundantRequireStatement
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -313,7 +313,7 @@ module Datadog
|
|
313
313
|
|
314
314
|
# Can be used to enable/disable the collection of heap profiles.
|
315
315
|
#
|
316
|
-
# This feature is
|
316
|
+
# This feature is in preview and disabled by default. Requires Ruby 3.1+.
|
317
317
|
#
|
318
318
|
# @warn To enable heap profiling you are required to also enable allocation profiling.
|
319
319
|
#
|
@@ -326,12 +326,12 @@ module Datadog
|
|
326
326
|
|
327
327
|
# Can be used to enable/disable the collection of heap size profiles.
|
328
328
|
#
|
329
|
-
# This feature is
|
329
|
+
# This feature is in preview and by default is enabled whenever heap profiling is enabled.
|
330
330
|
#
|
331
|
-
# @warn
|
331
|
+
# @warn Heap size profiling depends on allocation and heap profiling, so they must be enabled as well.
|
332
332
|
#
|
333
|
-
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED` environment variable as a boolean, otherwise
|
334
|
-
#
|
333
|
+
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED` environment variable as a boolean, otherwise it
|
334
|
+
# follows the value of `experimental_heap_enabled`.
|
335
335
|
option :experimental_heap_size_enabled do |o|
|
336
336
|
o.type :bool
|
337
337
|
o.env 'DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED'
|
@@ -341,17 +341,19 @@ module Datadog
|
|
341
341
|
# Can be used to configure the heap sampling rate: a heap sample will be collected for every x allocation
|
342
342
|
# samples.
|
343
343
|
#
|
344
|
-
# The
|
345
|
-
#
|
344
|
+
# The higher the value, the less accuracy in heap tracking but the smaller the overhead.
|
345
|
+
#
|
346
|
+
# If you needed to tweak this, please tell us why on <https://github.com/DataDog/dd-trace-rb/issues/new>,
|
347
|
+
# so we can fix it!
|
346
348
|
#
|
347
349
|
# The effective heap sampling rate in terms of allocations (not allocation samples) can be calculated via
|
348
350
|
# effective_heap_sample_rate = allocation_sample_rate * heap_sample_rate.
|
349
351
|
#
|
350
|
-
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SAMPLE_RATE` environment variable, otherwise `
|
352
|
+
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SAMPLE_RATE` environment variable, otherwise `1`.
|
351
353
|
option :experimental_heap_sample_rate do |o|
|
352
354
|
o.type :int
|
353
355
|
o.env 'DD_PROFILING_EXPERIMENTAL_HEAP_SAMPLE_RATE'
|
354
|
-
o.default
|
356
|
+
o.default 1
|
355
357
|
end
|
356
358
|
|
357
359
|
# Can be used to disable checking which version of `libmysqlclient` is being used by the `mysql2` gem.
|
@@ -454,7 +456,7 @@ module Datadog
|
|
454
456
|
o.after_set do |_, _, precedence|
|
455
457
|
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
456
458
|
Core.log_deprecation(key: :experimental_crash_tracking_enabled) do
|
457
|
-
'The profiling.advanced.experimental_crash_tracking_enabled setting has been deprecated for removal '\
|
459
|
+
'The profiling.advanced.experimental_crash_tracking_enabled setting has been deprecated for removal ' \
|
458
460
|
'and no longer does anything. Please remove it from your Datadog.configure block.'
|
459
461
|
end
|
460
462
|
end
|
@@ -542,6 +544,16 @@ module Datadog
|
|
542
544
|
o.env 'DD_PROFILING_HEAP_CLEAN_AFTER_GC_ENABLED'
|
543
545
|
o.default true
|
544
546
|
end
|
547
|
+
|
548
|
+
# Controls if the profiler should use native filenames for frames in stack traces for functions implemented using
|
549
|
+
# native code. Setting to `false` will make the profiler fall back to default Ruby stack trace behavior (only show .rb files).
|
550
|
+
#
|
551
|
+
# @default true
|
552
|
+
option :native_filenames_enabled do |o|
|
553
|
+
o.type :bool
|
554
|
+
o.env 'DD_PROFILING_NATIVE_FILENAMES_ENABLED'
|
555
|
+
o.default true
|
556
|
+
end
|
545
557
|
end
|
546
558
|
|
547
559
|
# @public_api
|
@@ -572,7 +584,7 @@ module Datadog
|
|
572
584
|
|
573
585
|
option :experimental_runtime_id_enabled do |o|
|
574
586
|
o.type :bool
|
575
|
-
o.env 'DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED'
|
587
|
+
o.env ['DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED', 'DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED']
|
576
588
|
o.default false
|
577
589
|
end
|
578
590
|
|
@@ -641,11 +653,11 @@ module Datadog
|
|
641
653
|
val ||= ''
|
642
654
|
# maps OpenTelemetry semantic attributes to Datadog tags
|
643
655
|
key = case key.downcase
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
656
|
+
when 'deployment.environment' then 'env'
|
657
|
+
when 'service.version' then 'version'
|
658
|
+
when 'service.name' then 'service'
|
659
|
+
else key
|
660
|
+
end
|
649
661
|
result[key] = val unless key.empty?
|
650
662
|
end
|
651
663
|
end
|
@@ -995,7 +1007,7 @@ module Datadog
|
|
995
1007
|
# Keep this extension here for now to keep things working.
|
996
1008
|
extend Datadog::Tracing::Configuration::Settings
|
997
1009
|
end
|
998
|
-
#
|
1010
|
+
# standard:enable Metrics/BlockLength
|
999
1011
|
end
|
1000
1012
|
end
|
1001
1013
|
end
|
@@ -14,8 +14,7 @@ module Datadog
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.configuration
|
17
|
-
|
18
|
-
@configuration ||= {} # TODO: After libdatadog 17.1 release, delete this line
|
17
|
+
@configuration ||= StableConfig.extract_configuration
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -235,16 +235,14 @@ module Datadog
|
|
235
235
|
end
|
236
236
|
|
237
237
|
COMPONENTS_WRITE_LOCK.synchronize do
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
nil
|
247
|
-
end
|
238
|
+
yield write_components
|
239
|
+
rescue ThreadError => e
|
240
|
+
logger_without_components.error(
|
241
|
+
'Detected deadlock during datadog initialization. ' \
|
242
|
+
'Please report this at https://github.com/datadog/dd-trace-rb/blob/master/CONTRIBUTING.md#found-a-bug' \
|
243
|
+
"\n\tSource:\n\t#{Array(e.backtrace).join("\n\t")}"
|
244
|
+
)
|
245
|
+
nil
|
248
246
|
end
|
249
247
|
end
|
250
248
|
|
@@ -267,12 +265,14 @@ module Datadog
|
|
267
265
|
components = Components.new(settings)
|
268
266
|
|
269
267
|
# Carry over state from existing components to the new ones.
|
270
|
-
# Currently
|
271
|
-
#
|
272
|
-
#
|
273
|
-
|
274
|
-
|
275
|
-
|
268
|
+
# Currently:
|
269
|
+
# 1. If we already started the remote component (which
|
270
|
+
# happens after a request goes through installed Rack middleware),
|
271
|
+
# we will start the new remote component as well.
|
272
|
+
# 2. If telemetry has been enabled and is enabled in the new
|
273
|
+
# component tree, we send AppConfigurationChange event instead
|
274
|
+
# of AppStarted event.
|
275
|
+
old_state = old.state
|
276
276
|
|
277
277
|
old.shutdown!(components)
|
278
278
|
components.startup!(settings, old_state: old_state)
|
@@ -92,7 +92,8 @@ module Datadog
|
|
92
92
|
path_to_crashtracking_receiver_binary: path_to_crashtracking_receiver_binary,
|
93
93
|
ld_library_path: ld_library_path,
|
94
94
|
tags_as_array: tags.to_a,
|
95
|
-
|
95
|
+
# @ivoanjo: On my machine this needs to be > 5 seconds, and seems to work with 10; the extra 15 is extra margin
|
96
|
+
upload_timeout_seconds: 15,
|
96
97
|
)
|
97
98
|
logger.debug("Crash tracking action: #{action} successful")
|
98
99
|
rescue => e
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../tag_builder'
|
3
4
|
require_relative '../utils'
|
4
|
-
require_relative '../environment/socket'
|
5
|
-
require_relative '../environment/identity'
|
6
|
-
require_relative '../environment/git'
|
7
5
|
|
8
6
|
module Datadog
|
9
7
|
module Core
|
@@ -11,27 +9,11 @@ module Datadog
|
|
11
9
|
# This module builds a hash of tags
|
12
10
|
module TagBuilder
|
13
11
|
def self.call(settings)
|
14
|
-
hash =
|
15
|
-
'host' => Environment::Socket.hostname,
|
16
|
-
'process_id' => Process.pid.to_s,
|
17
|
-
'runtime_engine' => Environment::Identity.lang_engine,
|
18
|
-
'runtime-id' => Environment::Identity.id,
|
19
|
-
'runtime_platform' => Environment::Identity.lang_platform,
|
20
|
-
'runtime_version' => Environment::Identity.lang_version,
|
21
|
-
'env' => settings.env,
|
22
|
-
'service' => settings.service,
|
23
|
-
'version' => settings.version,
|
24
|
-
'git.repository_url' => Environment::Git.git_repository_url,
|
25
|
-
'git.commit.sha' => Environment::Git.git_commit_sha,
|
12
|
+
hash = Core::TagBuilder.tags(settings).merge(
|
26
13
|
'is_crash' => 'true',
|
27
|
-
|
28
|
-
'library_version' => Core::Environment::Identity.gem_datadog_version,
|
29
|
-
}.compact
|
14
|
+
)
|
30
15
|
|
31
|
-
|
32
|
-
settings.tags.merge(hash).each_with_object({}) do |(key, value), h|
|
33
|
-
h[Utils.utf8_encode(key)] = Utils.utf8_encode(value)
|
34
|
-
end
|
16
|
+
Utils.encode_tags(hash)
|
35
17
|
end
|
36
18
|
end
|
37
19
|
end
|
@@ -23,20 +23,18 @@ module Datadog
|
|
23
23
|
|
24
24
|
def descriptors(process = 'self')
|
25
25
|
[].tap do |descriptors|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
descriptors << parse(line) unless line.empty?
|
33
|
-
end
|
26
|
+
filepath = "/proc/#{process}/cgroup"
|
27
|
+
|
28
|
+
if File.exist?(filepath)
|
29
|
+
File.foreach("/proc/#{process}/cgroup") do |line|
|
30
|
+
line = line.strip
|
31
|
+
descriptors << parse(line) unless line.empty?
|
34
32
|
end
|
35
|
-
rescue StandardError => e
|
36
|
-
Datadog.logger.error(
|
37
|
-
"Error while parsing cgroup. Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
38
|
-
)
|
39
33
|
end
|
34
|
+
rescue => e
|
35
|
+
Datadog.logger.error(
|
36
|
+
"Error while parsing cgroup. Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
37
|
+
)
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
@@ -37,52 +37,50 @@ module Datadog
|
|
37
37
|
|
38
38
|
def descriptor
|
39
39
|
@descriptor ||= Descriptor.new.tap do |descriptor|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
40
|
+
Cgroup.descriptors.each do |cgroup_descriptor|
|
41
|
+
# Parse container data from cgroup descriptor
|
42
|
+
path = cgroup_descriptor.path
|
43
|
+
next if path.nil?
|
44
|
+
|
45
|
+
# Split path into parts
|
46
|
+
parts = path.split('/')
|
47
|
+
parts.shift # Remove leading empty part
|
48
|
+
|
49
|
+
# Read info from path
|
50
|
+
next if parts.empty?
|
51
|
+
|
52
|
+
platform = parts[0][PLATFORM_REGEX, :platform]
|
53
|
+
container_id, task_uid = nil
|
54
|
+
|
55
|
+
case parts.length
|
56
|
+
when 0..1
|
57
|
+
next
|
58
|
+
when 2
|
59
|
+
container_id = parts[-1][CONTAINER_REGEX, :container] \
|
60
|
+
|| parts[-1][FARGATE_14_CONTAINER_REGEX, :container]
|
61
|
+
else
|
62
|
+
if (container_id = parts[-1][CONTAINER_REGEX, :container])
|
63
|
+
task_uid = parts[-2][POD_REGEX, :pod] || parts[1][POD_REGEX, :pod]
|
62
64
|
else
|
63
|
-
|
64
|
-
task_uid = parts[-2][POD_REGEX, :pod] || parts[1][POD_REGEX, :pod]
|
65
|
-
else
|
66
|
-
container_id = parts[-1][FARGATE_14_CONTAINER_REGEX, :container]
|
67
|
-
end
|
65
|
+
container_id = parts[-1][FARGATE_14_CONTAINER_REGEX, :container]
|
68
66
|
end
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
# If container ID wasn't found, ignore.
|
70
|
+
# Path might describe a non-container environment.
|
71
|
+
next if container_id.nil?
|
73
72
|
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
descriptor.platform = platform
|
74
|
+
descriptor.container_id = container_id
|
75
|
+
descriptor.task_uid = task_uid
|
77
76
|
|
78
|
-
|
79
|
-
end
|
80
|
-
rescue StandardError => e
|
81
|
-
Datadog.logger.error(
|
82
|
-
"Error while parsing container info. Cause: #{e.class.name} #{e.message} " \
|
83
|
-
"Location: #{Array(e.backtrace).first}"
|
84
|
-
)
|
77
|
+
break
|
85
78
|
end
|
79
|
+
rescue => e
|
80
|
+
Datadog.logger.error(
|
81
|
+
"Error while parsing container info. Cause: #{e.class.name} #{e.message} " \
|
82
|
+
"Location: #{Array(e.backtrace).first}"
|
83
|
+
)
|
86
84
|
end
|
87
85
|
end
|
88
86
|
end
|
@@ -9,11 +9,11 @@ module Datadog
|
|
9
9
|
module Ext
|
10
10
|
# e.g for CRuby '3.0.1', for JRuby '9.2.19.0', for TruffleRuby '21.1.0'
|
11
11
|
ENGINE_VERSION = if defined?(RUBY_ENGINE_VERSION)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
RUBY_ENGINE_VERSION
|
13
|
+
else
|
14
|
+
# CRuby < 2.3 doesn't support RUBY_ENGINE_VERSION
|
15
|
+
RUBY_VERSION
|
16
|
+
end
|
17
17
|
|
18
18
|
ENV_API_KEY = 'DD_API_KEY'
|
19
19
|
ENV_ENVIRONMENT = 'DD_ENV'
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
FALLBACK_SERVICE_NAME =
|
27
27
|
begin
|
28
28
|
File.basename($PROGRAM_NAME, '.*')
|
29
|
-
rescue
|
29
|
+
rescue
|
30
30
|
'ruby'
|
31
31
|
end.freeze
|
32
32
|
|
@@ -67,12 +67,12 @@ module Datadog
|
|
67
67
|
|
68
68
|
rest.split('.').tap do |segments|
|
69
69
|
if segments.length >= 4
|
70
|
-
pre
|
71
|
-
build = "+#{segments.join(
|
70
|
+
pre = "-#{segments.shift}"
|
71
|
+
build = "+#{segments.join(".")}"
|
72
72
|
elsif segments.length == 1
|
73
73
|
pre = "-#{segments.shift}"
|
74
74
|
else
|
75
|
-
build = "+#{segments.join(
|
75
|
+
build = "+#{segments.join(".")}"
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -13,18 +13,18 @@ module Datadog
|
|
13
13
|
|
14
14
|
# @return [String] ISA of host; `uname -m`
|
15
15
|
def architecture
|
16
|
-
Identity.lang_version >= '2.2' ? Etc.uname[:machine] : Gem::Platform.local.cpu
|
16
|
+
(Identity.lang_version >= '2.2') ? Etc.uname[:machine] : Gem::Platform.local.cpu
|
17
17
|
end
|
18
18
|
|
19
19
|
# @return [String] name of host; `uname -n`
|
20
20
|
def hostname
|
21
|
-
Identity.lang_version >= '2.2' ? Etc.uname[:nodename] : nil
|
21
|
+
(Identity.lang_version >= '2.2') ? Etc.uname[:nodename] : nil
|
22
22
|
end
|
23
23
|
|
24
24
|
# System name, normally `Linux` or `Darwin` (but 'Mac OS X' on JRuby);
|
25
25
|
# @return [String] name of kernel; `uname -s`.
|
26
26
|
def kernel_name
|
27
|
-
Identity.lang_version >= '2.2' ? Etc.uname[:sysname] : Gem::Platform.local.os.capitalize
|
27
|
+
(Identity.lang_version >= '2.2') ? Etc.uname[:sysname] : Gem::Platform.local.os.capitalize
|
28
28
|
end
|
29
29
|
|
30
30
|
# @return [String] kernel release; `uname -r`
|
data/lib/datadog/core/error.rb
CHANGED
@@ -11,12 +11,17 @@ module Datadog
|
|
11
11
|
class << self
|
12
12
|
def build_from(value)
|
13
13
|
case value
|
14
|
-
|
15
|
-
when Array then new(*value)
|
14
|
+
# A Ruby {Exception} is the most common parameter type.
|
16
15
|
when Exception then new(value.class, value.message, full_backtrace(value))
|
17
|
-
|
16
|
+
# steep:ignore:start
|
17
|
+
# Steep doesn't like an array with up to 3 elements to be passed here: it thinks the array is unbounded.
|
18
|
+
when Array then new(*value)
|
19
|
+
# Steep can not follow the logic inside the lambda, thus it doesn't know `value` responds to `:message`.
|
20
|
+
when ->(v) { v.respond_to?(:message) } then new(value.class, value.message)
|
21
|
+
# steep:ignore:end
|
18
22
|
when String then new(nil, value)
|
19
|
-
|
23
|
+
when Error then value
|
24
|
+
else Error.new # Blank error
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
@@ -34,7 +39,7 @@ module Datadog
|
|
34
39
|
# but it's around 3x faster in our benchmark test
|
35
40
|
# at `error_spec.rb`.
|
36
41
|
def full_backtrace(ex)
|
37
|
-
backtrace =
|
42
|
+
backtrace = +''
|
38
43
|
backtrace_for(ex, backtrace)
|
39
44
|
|
40
45
|
# Avoid circular causes
|
@@ -75,7 +80,7 @@ module Datadog
|
|
75
80
|
if trace[1]
|
76
81
|
# Ident stack trace for caller lines, to separate
|
77
82
|
# them from the main error lines.
|
78
|
-
trace[1..-1]
|
83
|
+
trace[1..-1]&.each do |line|
|
79
84
|
backtrace << "\n\tfrom "
|
80
85
|
backtrace << line
|
81
86
|
end
|
@@ -92,9 +97,6 @@ module Datadog
|
|
92
97
|
@message = Utils.utf8_encode(message)
|
93
98
|
@backtrace = Utils.utf8_encode(backtrace)
|
94
99
|
end
|
95
|
-
|
96
|
-
BlankError = Error.new
|
97
|
-
ContainsMessage = ->(v) { v.respond_to?(:message) }
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|