datadog 2.30.0 → 2.31.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 +44 -1
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.c +18 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +10 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +2 -0
- data/ext/libdatadog_api/crashtracker.c +5 -8
- data/ext/libdatadog_api/datadog_ruby_common.c +18 -0
- data/ext/libdatadog_api/datadog_ruby_common.h +10 -0
- data/ext/libdatadog_api/di.c +79 -0
- data/ext/libdatadog_api/extconf.rb +2 -0
- data/ext/libdatadog_api/init.c +5 -2
- data/ext/libdatadog_extconf_helpers.rb +9 -1
- data/lib/datadog/ai_guard/component.rb +2 -0
- data/lib/datadog/ai_guard/contrib/ruby_llm/chat_instrumentation.rb +41 -3
- data/lib/datadog/ai_guard/evaluation/content_builder.rb +31 -0
- data/lib/datadog/ai_guard/evaluation/content_part.rb +36 -0
- data/lib/datadog/ai_guard/evaluation/no_op_result.rb +3 -1
- data/lib/datadog/ai_guard/evaluation/request.rb +14 -9
- data/lib/datadog/ai_guard/evaluation/result.rb +3 -1
- data/lib/datadog/ai_guard/evaluation.rb +36 -7
- data/lib/datadog/ai_guard.rb +26 -8
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +11 -7
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +6 -7
- data/lib/datadog/appsec/contrib/rails/patcher.rb +2 -2
- data/lib/datadog/appsec/instrumentation/gateway.rb +0 -13
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +2 -0
- data/lib/datadog/appsec/utils/http/media_type.rb +1 -2
- data/lib/datadog/appsec/utils/http/url_encoded.rb +2 -2
- data/lib/datadog/appsec.rb +5 -9
- data/lib/datadog/core/configuration/base.rb +17 -5
- data/lib/datadog/core/configuration/components.rb +21 -8
- data/lib/datadog/core/configuration/config_helper.rb +9 -0
- data/lib/datadog/core/configuration/option.rb +30 -5
- data/lib/datadog/core/configuration/option_definition.rb +38 -12
- data/lib/datadog/core/configuration/options.rb +40 -6
- data/lib/datadog/core/configuration/settings.rb +15 -0
- data/lib/datadog/core/configuration/supported_configurations.rb +1 -0
- data/lib/datadog/core/contrib/rails/railtie.rb +32 -0
- data/lib/datadog/core/contrib/rails/utils.rb +7 -3
- data/lib/datadog/core/crashtracking/component.rb +3 -3
- data/lib/datadog/core/environment/container.rb +2 -2
- data/lib/datadog/core/environment/ext.rb +1 -0
- data/lib/datadog/core/environment/identity.rb +25 -3
- data/lib/datadog/core/environment/process.rb +12 -0
- data/lib/datadog/core/metrics/client.rb +5 -5
- data/lib/datadog/core/remote/component.rb +38 -21
- data/lib/datadog/core/runtime/metrics.rb +1 -1
- data/lib/datadog/core/telemetry/component.rb +3 -0
- data/lib/datadog/core/telemetry/event/app_client_configuration_change.rb +2 -3
- data/lib/datadog/core/telemetry/event/app_extended_heartbeat.rb +32 -0
- data/lib/datadog/core/telemetry/event/app_started.rb +151 -169
- data/lib/datadog/core/telemetry/event.rb +1 -7
- data/lib/datadog/core/telemetry/ext.rb +1 -0
- data/lib/datadog/core/telemetry/transport/http/telemetry.rb +5 -0
- data/lib/datadog/core/telemetry/worker.rb +20 -0
- data/lib/datadog/core/utils/only_once.rb +1 -1
- data/lib/datadog/core/utils/spawn_monkey_patch.rb +36 -0
- data/lib/datadog/core/workers/async.rb +1 -1
- data/lib/datadog/core.rb +0 -1
- data/lib/datadog/data_streams/pathway_context.rb +1 -1
- data/lib/datadog/di/boot.rb +2 -4
- data/lib/datadog/di/component.rb +4 -0
- data/lib/datadog/di/instrumenter.rb +10 -4
- data/lib/datadog/di/probe_notification_builder.rb +109 -1
- data/lib/datadog/di/serializer.rb +1 -1
- data/lib/datadog/di.rb +81 -0
- data/lib/datadog/kit/enable_core_dumps.rb +1 -1
- data/lib/datadog/open_feature/evaluation_engine.rb +1 -1
- data/lib/datadog/open_feature/exposures/reporter.rb +1 -1
- data/lib/datadog/open_feature/exposures/worker.rb +1 -1
- data/lib/datadog/open_feature/remote.rb +1 -1
- data/lib/datadog/open_feature/transport.rb +1 -1
- data/lib/datadog/opentelemetry/configuration/settings.rb +2 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +2 -3
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +1 -1
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/component.rb +11 -1
- data/lib/datadog/profiling/load_native_extension.rb +1 -1
- data/lib/datadog/profiling/profiler.rb +0 -4
- data/lib/datadog/profiling/scheduler.rb +2 -2
- data/lib/datadog/profiling/tasks/exec.rb +2 -2
- data/lib/datadog/profiling/tasks/setup.rb +2 -2
- data/lib/datadog/profiling.rb +1 -2
- data/lib/datadog/single_step_instrument.rb +1 -1
- data/lib/datadog/tracing/buffer.rb +3 -3
- data/lib/datadog/tracing/component.rb +11 -0
- data/lib/datadog/tracing/configuration/settings.rb +2 -1
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -2
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb +20 -0
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/patcher.rb +3 -1
- data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/events/discard.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/events/perform.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +1 -1
- data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +1 -1
- data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +2 -2
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/configurable.rb +18 -3
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/excon/middleware.rb +2 -2
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +2 -2
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +5 -5
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/patcher.rb +0 -1
- data/lib/datadog/tracing/contrib/rails/runner.rb +1 -1
- data/lib/datadog/tracing/contrib/rake/instrumentation.rb +2 -2
- data/lib/datadog/tracing/contrib/redis/tags.rb +1 -1
- data/lib/datadog/tracing/contrib/status_range_matcher.rb +4 -0
- data/lib/datadog/tracing/contrib/stripe/request.rb +1 -1
- data/lib/datadog/tracing/distributed/datadog.rb +4 -2
- data/lib/datadog/tracing/event.rb +1 -1
- data/lib/datadog/tracing/remote.rb +1 -1
- data/lib/datadog/tracing/sampling/ext.rb +2 -0
- data/lib/datadog/tracing/sampling/priority_sampler.rb +13 -0
- data/lib/datadog/tracing/sampling/rule.rb +1 -1
- data/lib/datadog/tracing/sampling/rule_sampler.rb +54 -25
- data/lib/datadog/tracing/sampling/span/rule_parser.rb +1 -1
- data/lib/datadog/tracing/span_operation.rb +1 -1
- data/lib/datadog/tracing/trace_operation.rb +50 -6
- data/lib/datadog/tracing/tracer.rb +25 -0
- data/lib/datadog/tracing/transport/io/client.rb +1 -1
- data/lib/datadog/tracing/transport/trace_formatter.rb +1 -1
- data/lib/datadog/version.rb +1 -1
- metadata +13 -7
|
@@ -49,7 +49,7 @@ module Datadog
|
|
|
49
49
|
span.set_tag(Ext::TAG_INSTANTIATION_CLASS_NAME, payload.fetch(:class_name))
|
|
50
50
|
span.set_tag(Ext::TAG_INSTANTIATION_RECORD_COUNT, payload.fetch(:record_count))
|
|
51
51
|
rescue => e
|
|
52
|
-
Datadog.logger.error(e.
|
|
52
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
53
53
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -69,7 +69,7 @@ module Datadog
|
|
|
69
69
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, config[:host]) if config[:host]
|
|
70
70
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, config[:port]) if config[:port]
|
|
71
71
|
rescue => e
|
|
72
|
-
Datadog.logger.error(e.
|
|
72
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
73
73
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -77,7 +77,7 @@ module Datadog
|
|
|
77
77
|
# in case.
|
|
78
78
|
Datadog.logger.debug(
|
|
79
79
|
"connection_id #{connection_id} does not represent a valid object. " \
|
|
80
|
-
"Cause: #{e.class
|
|
80
|
+
"Cause: #{e.class}: #{e} Source: #{Array(e.backtrace).first}"
|
|
81
81
|
)
|
|
82
82
|
end
|
|
83
83
|
else
|
|
@@ -125,7 +125,7 @@ module Datadog
|
|
|
125
125
|
@block&.call(span, name, id, payload)
|
|
126
126
|
rescue => e
|
|
127
127
|
Datadog.logger.debug(
|
|
128
|
-
"ActiveSupport::Notifications handler for '#{name}' failed: #{e.class
|
|
128
|
+
"ActiveSupport::Notifications handler for '#{name}' failed: #{e.class}: #{e}"
|
|
129
129
|
)
|
|
130
130
|
end
|
|
131
131
|
end
|
|
@@ -147,7 +147,7 @@ module Datadog
|
|
|
147
147
|
callback.call(event, key, *args)
|
|
148
148
|
rescue => e
|
|
149
149
|
Datadog.logger.debug(
|
|
150
|
-
"ActiveSupport::Notifications '#{key}' callback for '#{event}' failed: #{e.class
|
|
150
|
+
"ActiveSupport::Notifications '#{key}' callback for '#{event}' failed: #{e.class}: #{e}"
|
|
151
151
|
)
|
|
152
152
|
end
|
|
153
153
|
end
|
|
@@ -90,7 +90,7 @@ module Datadog
|
|
|
90
90
|
|
|
91
91
|
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
|
92
92
|
rescue => e
|
|
93
|
-
Datadog.logger.error(e.
|
|
93
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
94
94
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
95
95
|
end
|
|
96
96
|
# rubocop:enable Metrics/MethodLength
|
|
@@ -45,8 +45,11 @@ module Datadog
|
|
|
45
45
|
config = if matcher == :default
|
|
46
46
|
default_configuration
|
|
47
47
|
else
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
resolver.get(matcher) || begin
|
|
49
|
+
new_config = new_configuration
|
|
50
|
+
set_integration_settings_path!(new_config)
|
|
51
|
+
resolver.add(matcher, new_config)
|
|
52
|
+
end
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
# Apply the settings
|
|
@@ -67,11 +70,23 @@ module Datadog
|
|
|
67
70
|
#
|
|
68
71
|
# @return [Datadog::Tracing::Contrib::Configuration::Settings] the memoized integration-specific settings object
|
|
69
72
|
def default_configuration
|
|
70
|
-
@default_configuration ||=
|
|
73
|
+
@default_configuration ||= begin
|
|
74
|
+
configuration = new_configuration
|
|
75
|
+
set_integration_settings_path!(configuration)
|
|
76
|
+
configuration
|
|
77
|
+
end
|
|
71
78
|
end
|
|
72
79
|
|
|
73
80
|
protected
|
|
74
81
|
|
|
82
|
+
def set_integration_settings_path!(configuration)
|
|
83
|
+
# name is called from Registerable::InstanceMethods#name
|
|
84
|
+
# which is set by register_as
|
|
85
|
+
return unless respond_to?(:name)
|
|
86
|
+
|
|
87
|
+
configuration.class.settings_path = "tracing.#{name}" if configuration.class.respond_to?(:settings_path=)
|
|
88
|
+
end
|
|
89
|
+
|
|
75
90
|
# Returns a new configuration object for this integration.
|
|
76
91
|
#
|
|
77
92
|
# This method normally needs to be overridden for each integration
|
|
@@ -98,7 +98,7 @@ module Datadog
|
|
|
98
98
|
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
|
99
99
|
rescue => e
|
|
100
100
|
# TODO: Refactor the code to streamline the execution without ensure
|
|
101
|
-
Datadog.logger.error(e.
|
|
101
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
102
102
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
103
103
|
ensure
|
|
104
104
|
# the call is still executed
|
|
@@ -40,7 +40,7 @@ module Datadog
|
|
|
40
40
|
span
|
|
41
41
|
end
|
|
42
42
|
rescue => e
|
|
43
|
-
Datadog.logger.debug
|
|
43
|
+
Datadog.logger.debug { "#{e.class}: #{e}" }
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
@stack.request_call(datum)
|
|
@@ -180,7 +180,7 @@ module Datadog
|
|
|
180
180
|
end
|
|
181
181
|
end
|
|
182
182
|
rescue => e
|
|
183
|
-
Datadog.logger.debug
|
|
183
|
+
Datadog.logger.debug { "#{e.class}: #{e}" }
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
def propagate!(trace, span, datum)
|
|
@@ -83,7 +83,7 @@ module Datadog
|
|
|
83
83
|
|
|
84
84
|
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
|
85
85
|
rescue => e
|
|
86
|
-
Datadog.logger.error(e.
|
|
86
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
87
87
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
88
88
|
end
|
|
89
89
|
# rubocop:enable Metrics/AbcSize
|
|
@@ -98,7 +98,7 @@ module Datadog
|
|
|
98
98
|
Datadog.configuration.tracing.header_tags.response_tags(env[:response_headers])
|
|
99
99
|
)
|
|
100
100
|
rescue => e
|
|
101
|
-
Datadog.logger.error(e.
|
|
101
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
102
102
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
103
103
|
end
|
|
104
104
|
# rubocop:enable Metrics/AbcSize
|
|
@@ -77,7 +77,7 @@ module Datadog
|
|
|
77
77
|
|
|
78
78
|
Thread.current[KEY_RUN] = true
|
|
79
79
|
rescue => e
|
|
80
|
-
Datadog.logger.error(e.
|
|
80
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
81
81
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -121,7 +121,7 @@ module Datadog
|
|
|
121
121
|
span.finish(finish)
|
|
122
122
|
end
|
|
123
123
|
rescue => e
|
|
124
|
-
Datadog.logger.error(e.
|
|
124
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
125
125
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
126
126
|
end
|
|
127
127
|
|
|
@@ -165,7 +165,7 @@ module Datadog
|
|
|
165
165
|
|
|
166
166
|
Thread.current[KEY_RENDER] = true
|
|
167
167
|
rescue => e
|
|
168
|
-
Datadog.logger.error(e.
|
|
168
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
169
169
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
170
170
|
end
|
|
171
171
|
|
|
@@ -190,7 +190,7 @@ module Datadog
|
|
|
190
190
|
span.finish(finish)
|
|
191
191
|
end
|
|
192
192
|
rescue => e
|
|
193
|
-
Datadog.logger.error(e.
|
|
193
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
194
194
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
195
195
|
end
|
|
196
196
|
|
|
@@ -229,7 +229,7 @@ module Datadog
|
|
|
229
229
|
span.finish(finish)
|
|
230
230
|
end
|
|
231
231
|
rescue => e
|
|
232
|
-
Datadog.logger.error(e.
|
|
232
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
233
233
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
234
234
|
end
|
|
235
235
|
|
|
@@ -84,7 +84,7 @@ module Datadog
|
|
|
84
84
|
span.resource = "#{method} #{quantized_url}"
|
|
85
85
|
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
|
86
86
|
rescue => e
|
|
87
|
-
Datadog.logger.error(e.
|
|
87
|
+
Datadog.logger.error("#{e.class}: #{e}")
|
|
88
88
|
Datadog::Core::Telemetry::Logger.report(e)
|
|
89
89
|
# TODO: Refactor the code to streamline the execution without ensure
|
|
90
90
|
ensure
|
|
@@ -18,7 +18,7 @@ module Datadog
|
|
|
18
18
|
app_config.log_tags << proc { Tracing.log_correlation if Datadog.configuration.tracing.log_injection }
|
|
19
19
|
rescue => e
|
|
20
20
|
Datadog.logger.warn(
|
|
21
|
-
"Unable to add Datadog Trace context to ActiveSupport::TaggedLogging: #{e.class
|
|
21
|
+
"Unable to add Datadog Trace context to ActiveSupport::TaggedLogging: #{e.class}: #{e}"
|
|
22
22
|
)
|
|
23
23
|
false
|
|
24
24
|
end
|
|
@@ -86,7 +86,7 @@ module Datadog
|
|
|
86
86
|
# Reads one more byte than the limit to allow us to check if the source exceeds the limit.
|
|
87
87
|
source = File.read(file, MAX_TAG_VALUE_SIZE + 1)
|
|
88
88
|
rescue => e
|
|
89
|
-
Datadog.logger.debug
|
|
89
|
+
Datadog.logger.debug { "Failed to read file '#{file}' for Rails runner: #{e.class}: #{e}" }
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
Tracing.trace(
|
|
@@ -66,7 +66,7 @@ module Datadog
|
|
|
66
66
|
span.set_tag(Ext::TAG_TASK_ARG_NAMES, arg_names)
|
|
67
67
|
span.set_tag(Ext::TAG_INVOKE_ARGS, quantize_args(args)) unless args.nil?
|
|
68
68
|
rescue => e
|
|
69
|
-
Datadog.logger.debug
|
|
69
|
+
Datadog.logger.debug { "Error while tracing Rake invoke: #{e.class}: #{e}" }
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def annotate_execute!(span, args)
|
|
@@ -75,7 +75,7 @@ module Datadog
|
|
|
75
75
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_EXECUTE)
|
|
76
76
|
span.set_tag(Ext::TAG_EXECUTE_ARGS, quantize_args(args.to_hash)) unless args.nil?
|
|
77
77
|
rescue => e
|
|
78
|
-
Datadog.logger.debug
|
|
78
|
+
Datadog.logger.debug { "Error while tracing Rake execute: #{e.class}: #{e}" }
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def quantize_args(args)
|
|
@@ -55,7 +55,7 @@ module Datadog
|
|
|
55
55
|
span.set_tag(Ext::TAG_REQUEST_PATH, event.path)
|
|
56
56
|
span.set_tag(Ext::TAG_REQUEST_NUM_RETRIES, event.num_retries.to_s)
|
|
57
57
|
rescue => e
|
|
58
|
-
Datadog.logger.debug
|
|
58
|
+
Datadog.logger.debug { "#{e.class}: #{e}" }
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def configuration
|
|
@@ -140,8 +140,9 @@ module Datadog
|
|
|
140
140
|
rescue => e
|
|
141
141
|
set_tags_propagation_error(reason: 'encoding_error')
|
|
142
142
|
::Datadog.logger.warn(
|
|
143
|
-
"Failed to inject x-datadog-tags: #{e.class
|
|
143
|
+
"Failed to inject x-datadog-tags: #{e.class}: #{e} at #{Array(e.backtrace).first}"
|
|
144
144
|
)
|
|
145
|
+
nil
|
|
145
146
|
end
|
|
146
147
|
|
|
147
148
|
# Import `x-datadog-tags` tags as trace distributed tags.
|
|
@@ -166,8 +167,9 @@ module Datadog
|
|
|
166
167
|
rescue => e
|
|
167
168
|
set_tags_propagation_error(reason: 'decoding_error')
|
|
168
169
|
::Datadog.logger.warn(
|
|
169
|
-
"Failed to extract x-datadog-tags: #{e.class
|
|
170
|
+
"Failed to extract x-datadog-tags: #{e.class}: #{e} at #{Array(e.backtrace).first}"
|
|
170
171
|
)
|
|
172
|
+
nil
|
|
171
173
|
end
|
|
172
174
|
|
|
173
175
|
def set_tags_propagation_error(reason:)
|
|
@@ -62,7 +62,7 @@ module Datadog
|
|
|
62
62
|
block.call(*args)
|
|
63
63
|
rescue => e
|
|
64
64
|
Datadog.logger.debug do
|
|
65
|
-
"Error while handling '#{name}' event with '#{block}': #{e.class
|
|
65
|
+
"Error while handling '#{name}' event with '#{block}': #{e.class}: #{e} " \
|
|
66
66
|
"at #{Array(e.backtrace).first}"
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -43,7 +43,7 @@ module Datadog
|
|
|
43
43
|
|
|
44
44
|
Datadog.send(:components).telemetry.client_configuration_change!(env_vars)
|
|
45
45
|
rescue => e
|
|
46
|
-
content.errored("#{e.class
|
|
46
|
+
content.errored("#{e.class}: #{e}: #{Array(e.backtrace).join("\n")}")
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def receivers(_telemetry)
|
|
@@ -47,6 +47,8 @@ module Datadog
|
|
|
47
47
|
MANUAL = '-4'
|
|
48
48
|
# Formerly AppSec.
|
|
49
49
|
ASM = '-5'
|
|
50
|
+
# AI Guard.
|
|
51
|
+
AI_GUARD = '-13'
|
|
50
52
|
# Dynamically configured rule, explicitly created by the user.
|
|
51
53
|
REMOTE_USER_RULE = '-11'
|
|
52
54
|
# Dynamically configured rule, automatically generated by Datadog.
|
|
@@ -77,6 +77,19 @@ module Datadog
|
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
def reconsider_sample_resource!(trace)
|
|
81
|
+
return unless @priority_sampler.respond_to?(:reconsider_sample_resource!)
|
|
82
|
+
|
|
83
|
+
preserving_sampling(trace) do
|
|
84
|
+
@priority_sampler.reconsider_sample_resource!(trace)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def resource_sampling?
|
|
89
|
+
@priority_sampler.respond_to?(:resource_sampling?) &&
|
|
90
|
+
@priority_sampler.resource_sampling?
|
|
91
|
+
end
|
|
92
|
+
|
|
80
93
|
# (see Datadog::Tracing::Sampling::RateByServiceSampler#update)
|
|
81
94
|
def update(rate_by_service, decision: nil)
|
|
82
95
|
@priority_sampler.update(rate_by_service, decision: decision)
|
|
@@ -34,7 +34,7 @@ module Datadog
|
|
|
34
34
|
@matcher.match?(trace)
|
|
35
35
|
rescue => e
|
|
36
36
|
Datadog.logger.error(
|
|
37
|
-
"Matcher failed. Cause: #{e.class
|
|
37
|
+
"Matcher failed. Cause: #{e.class}: #{e} Source: #{Array(e.backtrace).first}"
|
|
38
38
|
)
|
|
39
39
|
Datadog::Core::Telemetry::Logger.report(e, description: 'Matcher failed')
|
|
40
40
|
nil
|
|
@@ -50,6 +50,7 @@ module Datadog
|
|
|
50
50
|
# TODO: Simplify .tags access, as `Tracer#tags` can't be arbitrarily changed anymore
|
|
51
51
|
RateByServiceSampler.new(1.0, env: -> { Tracing.send(:tracer).tags['env'] })
|
|
52
52
|
end
|
|
53
|
+
@reconsider_sample_resource_enabled = @rules.any? { |rule| resource_rule?(rule) }
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def self.parse(rules, rate_limit, default_sample_rate)
|
|
@@ -84,7 +85,7 @@ module Datadog
|
|
|
84
85
|
new(parsed_rules, rate_limit: rate_limit, default_sample_rate: default_sample_rate)
|
|
85
86
|
rescue => e
|
|
86
87
|
Datadog.logger.warn do
|
|
87
|
-
"Could not parse trace sampling rules '#{rules}': #{e.class
|
|
88
|
+
"Could not parse trace sampling rules '#{rules}': #{e.class}: #{e} at #{Array(e.backtrace).first}"
|
|
88
89
|
end
|
|
89
90
|
|
|
90
91
|
nil
|
|
@@ -103,6 +104,18 @@ module Datadog
|
|
|
103
104
|
trace.sampled = sampled
|
|
104
105
|
end
|
|
105
106
|
|
|
107
|
+
def reconsider_sample_resource!(trace)
|
|
108
|
+
rule = @rules.find { |r| resource_rule?(r) && r.match?(trace) }
|
|
109
|
+
return if rule.nil?
|
|
110
|
+
|
|
111
|
+
reconsider_matching_rule!(trace, rule)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Do any rules match on the resource name?
|
|
115
|
+
def resource_sampling?
|
|
116
|
+
@reconsider_sample_resource_enabled
|
|
117
|
+
end
|
|
118
|
+
|
|
106
119
|
# @!visibility private
|
|
107
120
|
def update(*args, **kwargs)
|
|
108
121
|
return false unless @default_sampler.respond_to?(:update)
|
|
@@ -117,32 +130,10 @@ module Datadog
|
|
|
117
130
|
|
|
118
131
|
return yield(trace) if rule.nil?
|
|
119
132
|
|
|
120
|
-
|
|
121
|
-
sample_rate = rule.sample_rate(trace)
|
|
122
|
-
|
|
123
|
-
set_priority(trace, sampled)
|
|
124
|
-
set_rule_metrics(trace, sample_rate)
|
|
125
|
-
|
|
126
|
-
return false unless sampled
|
|
127
|
-
|
|
128
|
-
rate_limiter.allow?.tap do |allowed|
|
|
129
|
-
set_priority(trace, allowed)
|
|
130
|
-
set_limiter_metrics(trace, rate_limiter.effective_rate)
|
|
131
|
-
|
|
132
|
-
provenance = case rule.provenance
|
|
133
|
-
when Rule::PROVENANCE_REMOTE_USER
|
|
134
|
-
Ext::Decision::REMOTE_USER_RULE
|
|
135
|
-
when Rule::PROVENANCE_REMOTE_DYNAMIC
|
|
136
|
-
Ext::Decision::REMOTE_DYNAMIC_RULE
|
|
137
|
-
else
|
|
138
|
-
Ext::Decision::TRACE_SAMPLING_RULE
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
trace.set_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER, provenance)
|
|
142
|
-
end
|
|
133
|
+
apply_rule!(trace, rule)
|
|
143
134
|
rescue => e
|
|
144
135
|
Datadog.logger.error(
|
|
145
|
-
"Rule sampling failed. Cause: #{e.class
|
|
136
|
+
"Rule sampling failed. Cause: #{e.class}: #{e} Source: #{Array(e.backtrace).first}"
|
|
146
137
|
)
|
|
147
138
|
Datadog::Core::Telemetry::Logger.report(e, description: 'Rule sampling failed')
|
|
148
139
|
|
|
@@ -166,6 +157,44 @@ module Datadog
|
|
|
166
157
|
def set_limiter_metrics(trace, limiter_rate)
|
|
167
158
|
trace.rate_limiter_rate = limiter_rate
|
|
168
159
|
end
|
|
160
|
+
|
|
161
|
+
def apply_rule!(trace, rule)
|
|
162
|
+
sampled = rule.sample!(trace)
|
|
163
|
+
sample_rate = rule.sample_rate(trace)
|
|
164
|
+
|
|
165
|
+
set_priority(trace, sampled)
|
|
166
|
+
set_rule_metrics(trace, sample_rate)
|
|
167
|
+
|
|
168
|
+
return false unless sampled
|
|
169
|
+
|
|
170
|
+
rate_limiter.allow?.tap do |allowed|
|
|
171
|
+
set_priority(trace, allowed)
|
|
172
|
+
set_limiter_metrics(trace, rate_limiter.effective_rate)
|
|
173
|
+
trace.set_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER, provenance_for(rule))
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def provenance_for(rule)
|
|
178
|
+
case rule.provenance
|
|
179
|
+
when Rule::PROVENANCE_REMOTE_USER
|
|
180
|
+
Ext::Decision::REMOTE_USER_RULE
|
|
181
|
+
when Rule::PROVENANCE_REMOTE_DYNAMIC
|
|
182
|
+
Ext::Decision::REMOTE_DYNAMIC_RULE
|
|
183
|
+
else
|
|
184
|
+
Ext::Decision::TRACE_SAMPLING_RULE
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def resource_rule?(rule)
|
|
189
|
+
matcher = rule.matcher
|
|
190
|
+
matcher.respond_to?(:resource) && matcher.resource != Matcher::MATCH_ALL
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def reconsider_matching_rule!(trace, rule)
|
|
194
|
+
trace.agent_sample_rate = nil
|
|
195
|
+
trace.clear_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER)
|
|
196
|
+
apply_rule!(trace, rule)
|
|
197
|
+
end
|
|
169
198
|
end
|
|
170
199
|
end
|
|
171
200
|
end
|
|
@@ -166,7 +166,7 @@ module Datadog
|
|
|
166
166
|
# end its execution (either due to a system error or graceful shutdown).
|
|
167
167
|
# @type var e: Exception?
|
|
168
168
|
# Steep: https://github.com/soutaro/steep/issues/919
|
|
169
|
-
return_value = yield(self) unless e && !e.is_a?(StandardError)
|
|
169
|
+
return_value = yield(self) unless e && !e.is_a?(StandardError)
|
|
170
170
|
end
|
|
171
171
|
# rubocop:disable Lint/RescueException
|
|
172
172
|
# Here we really want to catch *any* exception, not only StandardError,
|