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
@@ -35,7 +35,7 @@ module Datadog
|
|
35
35
|
:start_time,
|
36
36
|
:trace_id,
|
37
37
|
:type
|
38
|
-
attr_accessor :links, :status
|
38
|
+
attr_accessor :links, :status, :span_events
|
39
39
|
|
40
40
|
def initialize(
|
41
41
|
name,
|
@@ -49,6 +49,7 @@ module Datadog
|
|
49
49
|
trace_id: nil,
|
50
50
|
type: nil,
|
51
51
|
links: nil,
|
52
|
+
span_events: nil,
|
52
53
|
id: nil
|
53
54
|
)
|
54
55
|
# Ensure dynamically created strings are UTF-8 encoded.
|
@@ -68,6 +69,8 @@ module Datadog
|
|
68
69
|
@status = 0
|
69
70
|
# stores array of span links
|
70
71
|
@links = links || []
|
72
|
+
# stores array of span events
|
73
|
+
@span_events = span_events || []
|
71
74
|
|
72
75
|
# start_time and end_time track wall clock. In Ruby, wall clock
|
73
76
|
# has less accuracy than monotonic clock, so if possible we look to only use wall clock
|
@@ -265,7 +268,7 @@ module Datadog
|
|
265
268
|
|
266
269
|
def set_error(e)
|
267
270
|
@status = Metadata::Ext::Errors::STATUS
|
268
|
-
|
271
|
+
set_error_tags(e)
|
269
272
|
end
|
270
273
|
|
271
274
|
# Return a string representation of the span.
|
@@ -455,6 +458,7 @@ module Datadog
|
|
455
458
|
type: @type,
|
456
459
|
trace_id: @trace_id,
|
457
460
|
links: @links,
|
461
|
+
events: @span_events,
|
458
462
|
service_entry: parent.nil? || (service && parent.service != service)
|
459
463
|
)
|
460
464
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../core/environment/identity'
|
4
4
|
require_relative '../core/utils'
|
5
|
-
|
5
|
+
require_relative 'tracer'
|
6
6
|
require_relative 'event'
|
7
7
|
require_relative 'metadata/tagging'
|
8
8
|
require_relative 'sampling/ext'
|
@@ -75,7 +75,9 @@ module Datadog
|
|
75
75
|
metrics: nil,
|
76
76
|
trace_state: nil,
|
77
77
|
trace_state_unknown_fields: nil,
|
78
|
-
remote_parent: false
|
78
|
+
remote_parent: false,
|
79
|
+
tracer: nil
|
80
|
+
|
79
81
|
)
|
80
82
|
# Attributes
|
81
83
|
@id = id || Tracing::Utils::TraceId.next_id
|
@@ -98,6 +100,7 @@ module Datadog
|
|
98
100
|
@profiling_enabled = profiling_enabled
|
99
101
|
@trace_state = trace_state
|
100
102
|
@trace_state_unknown_fields = trace_state_unknown_fields
|
103
|
+
@tracer = tracer
|
101
104
|
|
102
105
|
# Generic tags
|
103
106
|
set_tags(tags) if tags
|
@@ -161,6 +164,23 @@ module Datadog
|
|
161
164
|
@resource || (root_span && root_span.resource)
|
162
165
|
end
|
163
166
|
|
167
|
+
# When retrieving tags or metrics we need to include root span tags for sampling purposes
|
168
|
+
def get_tag(key)
|
169
|
+
super || (root_span && root_span.get_tag(key))
|
170
|
+
end
|
171
|
+
|
172
|
+
def get_metric(key)
|
173
|
+
super || (root_span && root_span.get_metric(key))
|
174
|
+
end
|
175
|
+
|
176
|
+
def tags
|
177
|
+
all_tags = {}
|
178
|
+
all_tags.merge!(root_span&.tags || {}) if root_span
|
179
|
+
all_tags.merge!(super)
|
180
|
+
|
181
|
+
all_tags
|
182
|
+
end
|
183
|
+
|
164
184
|
# Returns true if the resource has been explicitly set
|
165
185
|
#
|
166
186
|
# @return [Boolean]
|
@@ -284,10 +304,14 @@ module Datadog
|
|
284
304
|
# Returns a set of trace headers used for continuing traces.
|
285
305
|
# Used for propagation across execution contexts.
|
286
306
|
# Data should reflect the active state of the trace.
|
307
|
+
# DEV-3.0: Sampling is a side effect of generating the digest.
|
308
|
+
# We should move the sample call to inject and right before moving to new contexts(threads, forking etc.)
|
287
309
|
def to_digest
|
288
310
|
# Resolve current span ID
|
289
311
|
span_id = @active_span && @active_span.id
|
290
312
|
span_id ||= @parent_span_id unless finished?
|
313
|
+
# sample the trace_operation with the tracer
|
314
|
+
@tracer&.sample_trace(self) unless sampling_priority
|
291
315
|
|
292
316
|
TraceDigest.new(
|
293
317
|
span_id: span_id,
|
@@ -262,6 +262,17 @@ module Datadog
|
|
262
262
|
context.activate!(trace, &block)
|
263
263
|
end
|
264
264
|
|
265
|
+
# Sample a span, tagging the trace as appropriate.
|
266
|
+
def sample_trace(trace_op)
|
267
|
+
begin
|
268
|
+
@sampler.sample!(trace_op)
|
269
|
+
rescue StandardError => e
|
270
|
+
SAMPLE_TRACE_LOG_ONLY_ONCE.run do
|
271
|
+
Datadog.logger.warn { "Failed to sample trace: #{e.class.name} #{e} at #{Array(e.backtrace).first}" }
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
265
276
|
# @!visibility private
|
266
277
|
# TODO: make this private
|
267
278
|
def trace_completed
|
@@ -331,12 +342,14 @@ module Datadog
|
|
331
342
|
trace_state: digest.trace_state,
|
332
343
|
trace_state_unknown_fields: digest.trace_state_unknown_fields,
|
333
344
|
remote_parent: digest.span_remote,
|
345
|
+
tracer: self
|
334
346
|
)
|
335
347
|
else
|
336
348
|
TraceOperation.new(
|
337
349
|
hostname: hostname,
|
338
350
|
profiling_enabled: profiling_enabled,
|
339
351
|
remote_parent: false,
|
352
|
+
tracer: self
|
340
353
|
)
|
341
354
|
end
|
342
355
|
end
|
@@ -347,7 +360,6 @@ module Datadog
|
|
347
360
|
events.span_before_start.subscribe do |event_span_op, event_trace_op|
|
348
361
|
event_trace_op.service ||= @default_service
|
349
362
|
event_span_op.service ||= @default_service
|
350
|
-
sample_trace(event_trace_op) if event_span_op && event_span_op.parent_id == 0
|
351
363
|
end
|
352
364
|
|
353
365
|
events.span_finished.subscribe do |event_span, event_trace_op|
|
@@ -463,17 +475,6 @@ module Datadog
|
|
463
475
|
end
|
464
476
|
end
|
465
477
|
|
466
|
-
# Sample a span, tagging the trace as appropriate.
|
467
|
-
def sample_trace(trace_op)
|
468
|
-
begin
|
469
|
-
@sampler.sample!(trace_op)
|
470
|
-
rescue StandardError => e
|
471
|
-
SAMPLE_TRACE_LOG_ONLY_ONCE.run do
|
472
|
-
Datadog.logger.warn { "Failed to sample trace: #{e.class.name} #{e} at #{Array(e.backtrace).first}" }
|
473
|
-
end
|
474
|
-
end
|
475
|
-
end
|
476
|
-
|
477
478
|
SAMPLE_TRACE_LOG_ONLY_ONCE = Core::Utils::OnlyOnce.new
|
478
479
|
private_constant :SAMPLE_TRACE_LOG_ONLY_ONCE
|
479
480
|
|
@@ -492,6 +493,7 @@ module Datadog
|
|
492
493
|
|
493
494
|
# Flush finished spans from the trace buffer, send them to writer.
|
494
495
|
def flush_trace(trace_op)
|
496
|
+
sample_trace(trace_op) unless trace_op.sampling_priority
|
495
497
|
begin
|
496
498
|
trace = @trace_flush.consume!(trace_op)
|
497
499
|
write(trace) if trace && !trace.empty?
|
@@ -72,6 +72,9 @@ module Datadog
|
|
72
72
|
packer.write_map_header(number_of_elements_to_write) # Set header with how many elements in the map
|
73
73
|
end
|
74
74
|
|
75
|
+
# serialize span events as meta tags
|
76
|
+
span.set_tag('events', span.events.map(&:to_hash).to_json) if span.events.any?
|
77
|
+
|
75
78
|
# DEV: We use strings as keys here, instead of symbols, as
|
76
79
|
# DEV: MessagePack will ultimately convert them to strings.
|
77
80
|
# DEV: By providing strings directly, we skip this indirection operation.
|
@@ -43,7 +43,7 @@ module Datadog
|
|
43
43
|
traces = process_traces(traces)
|
44
44
|
flush_traces(traces)
|
45
45
|
rescue StandardError => e
|
46
|
-
Datadog.logger.
|
46
|
+
Datadog.logger.warn(
|
47
47
|
"Error while writing traces: dropped #{traces.length} items. Cause: #{e} Location: #{Array(e.backtrace).first}"
|
48
48
|
)
|
49
49
|
end
|
@@ -56,7 +56,7 @@ module Datadog
|
|
56
56
|
# ensures that the thread will not die because of an exception.
|
57
57
|
# TODO[manu]: findout the reason and reschedule the send if it's not
|
58
58
|
# a fatal exception
|
59
|
-
Datadog.logger.
|
59
|
+
Datadog.logger.warn(
|
60
60
|
"Error during traces flush: dropped #{traces.length} items. Cause: #{e} Location: #{Array(e.backtrace).first}"
|
61
61
|
)
|
62
62
|
end
|
data/lib/datadog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.0.0.1.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 12.0.0.1.0
|
69
69
|
description: |
|
70
70
|
datadog is Datadog's client library for Ruby. It includes a suite of tools
|
71
71
|
which provide visibility into the performance and security of Ruby applications,
|
@@ -77,6 +77,7 @@ executables:
|
|
77
77
|
extensions:
|
78
78
|
- ext/datadog_profiling_native_extension/extconf.rb
|
79
79
|
- ext/datadog_profiling_loader/extconf.rb
|
80
|
+
- ext/libdatadog_api/extconf.rb
|
80
81
|
extra_rdoc_files: []
|
81
82
|
files:
|
82
83
|
- CHANGELOG.md
|
@@ -106,8 +107,11 @@ files:
|
|
106
107
|
- ext/datadog_profiling_native_extension/collectors_stack.h
|
107
108
|
- ext/datadog_profiling_native_extension/collectors_thread_context.c
|
108
109
|
- ext/datadog_profiling_native_extension/collectors_thread_context.h
|
109
|
-
- ext/datadog_profiling_native_extension/
|
110
|
+
- ext/datadog_profiling_native_extension/datadog_ruby_common.c
|
111
|
+
- ext/datadog_profiling_native_extension/datadog_ruby_common.h
|
110
112
|
- ext/datadog_profiling_native_extension/extconf.rb
|
113
|
+
- ext/datadog_profiling_native_extension/gvl_profiling_helper.c
|
114
|
+
- ext/datadog_profiling_native_extension/gvl_profiling_helper.h
|
111
115
|
- ext/datadog_profiling_native_extension/heap_recorder.c
|
112
116
|
- ext/datadog_profiling_native_extension/heap_recorder.h
|
113
117
|
- ext/datadog_profiling_native_extension/helpers.h
|
@@ -126,6 +130,12 @@ files:
|
|
126
130
|
- ext/datadog_profiling_native_extension/stack_recorder.h
|
127
131
|
- ext/datadog_profiling_native_extension/time_helpers.c
|
128
132
|
- ext/datadog_profiling_native_extension/time_helpers.h
|
133
|
+
- ext/libdatadog_api/crashtracker.c
|
134
|
+
- ext/libdatadog_api/datadog_ruby_common.c
|
135
|
+
- ext/libdatadog_api/datadog_ruby_common.h
|
136
|
+
- ext/libdatadog_api/extconf.rb
|
137
|
+
- ext/libdatadog_api/macos_development.md
|
138
|
+
- ext/libdatadog_extconf_helpers.rb
|
129
139
|
- lib/datadog.rb
|
130
140
|
- lib/datadog/appsec.rb
|
131
141
|
- lib/datadog/appsec/assets.rb
|
@@ -148,8 +158,15 @@ files:
|
|
148
158
|
- lib/datadog/appsec/contrib/devise/patcher.rb
|
149
159
|
- lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb
|
150
160
|
- lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb
|
161
|
+
- lib/datadog/appsec/contrib/devise/patcher/rememberable_patch.rb
|
151
162
|
- lib/datadog/appsec/contrib/devise/resource.rb
|
152
163
|
- lib/datadog/appsec/contrib/devise/tracking.rb
|
164
|
+
- lib/datadog/appsec/contrib/graphql/appsec_trace.rb
|
165
|
+
- lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb
|
166
|
+
- lib/datadog/appsec/contrib/graphql/gateway/watcher.rb
|
167
|
+
- lib/datadog/appsec/contrib/graphql/integration.rb
|
168
|
+
- lib/datadog/appsec/contrib/graphql/patcher.rb
|
169
|
+
- lib/datadog/appsec/contrib/graphql/reactive/multiplex.rb
|
153
170
|
- lib/datadog/appsec/contrib/integration.rb
|
154
171
|
- lib/datadog/appsec/contrib/patcher.rb
|
155
172
|
- lib/datadog/appsec/contrib/rack/ext.rb
|
@@ -223,6 +240,9 @@ files:
|
|
223
240
|
- lib/datadog/core/configuration/option_definition.rb
|
224
241
|
- lib/datadog/core/configuration/options.rb
|
225
242
|
- lib/datadog/core/configuration/settings.rb
|
243
|
+
- lib/datadog/core/crashtracking/agent_base_url.rb
|
244
|
+
- lib/datadog/core/crashtracking/component.rb
|
245
|
+
- lib/datadog/core/crashtracking/tag_builder.rb
|
226
246
|
- lib/datadog/core/deprecations.rb
|
227
247
|
- lib/datadog/core/diagnostics/environment_logger.rb
|
228
248
|
- lib/datadog/core/diagnostics/health.rb
|
@@ -254,6 +274,7 @@ files:
|
|
254
274
|
- lib/datadog/core/metrics/metric.rb
|
255
275
|
- lib/datadog/core/metrics/options.rb
|
256
276
|
- lib/datadog/core/pin.rb
|
277
|
+
- lib/datadog/core/rate_limiter.rb
|
257
278
|
- lib/datadog/core/remote.rb
|
258
279
|
- lib/datadog/core/remote/client.rb
|
259
280
|
- lib/datadog/core/remote/client/capabilities.rb
|
@@ -291,6 +312,8 @@ files:
|
|
291
312
|
- lib/datadog/core/telemetry/http/ext.rb
|
292
313
|
- lib/datadog/core/telemetry/http/response.rb
|
293
314
|
- lib/datadog/core/telemetry/http/transport.rb
|
315
|
+
- lib/datadog/core/telemetry/logger.rb
|
316
|
+
- lib/datadog/core/telemetry/logging.rb
|
294
317
|
- lib/datadog/core/telemetry/metric.rb
|
295
318
|
- lib/datadog/core/telemetry/metrics_collection.rb
|
296
319
|
- lib/datadog/core/telemetry/metrics_manager.rb
|
@@ -310,6 +333,7 @@ files:
|
|
310
333
|
- lib/datadog/core/transport/request.rb
|
311
334
|
- lib/datadog/core/transport/response.rb
|
312
335
|
- lib/datadog/core/utils.rb
|
336
|
+
- lib/datadog/core/utils/at_fork_monkey_patch.rb
|
313
337
|
- lib/datadog/core/utils/base64.rb
|
314
338
|
- lib/datadog/core/utils/duration.rb
|
315
339
|
- lib/datadog/core/utils/forking.rb
|
@@ -335,6 +359,16 @@ files:
|
|
335
359
|
- lib/datadog/core/workers/polling.rb
|
336
360
|
- lib/datadog/core/workers/queue.rb
|
337
361
|
- lib/datadog/core/workers/runtime_metrics.rb
|
362
|
+
- lib/datadog/di.rb
|
363
|
+
- lib/datadog/di/code_tracker.rb
|
364
|
+
- lib/datadog/di/configuration.rb
|
365
|
+
- lib/datadog/di/configuration/settings.rb
|
366
|
+
- lib/datadog/di/error.rb
|
367
|
+
- lib/datadog/di/extensions.rb
|
368
|
+
- lib/datadog/di/probe.rb
|
369
|
+
- lib/datadog/di/probe_builder.rb
|
370
|
+
- lib/datadog/di/redactor.rb
|
371
|
+
- lib/datadog/di/serializer.rb
|
338
372
|
- lib/datadog/kit.rb
|
339
373
|
- lib/datadog/kit/appsec/events.rb
|
340
374
|
- lib/datadog/kit/enable_core_dumps.rb
|
@@ -357,11 +391,9 @@ files:
|
|
357
391
|
- lib/datadog/profiling/collectors/stack.rb
|
358
392
|
- lib/datadog/profiling/collectors/thread_context.rb
|
359
393
|
- lib/datadog/profiling/component.rb
|
360
|
-
- lib/datadog/profiling/crashtracker.rb
|
361
394
|
- lib/datadog/profiling/exporter.rb
|
362
395
|
- lib/datadog/profiling/ext.rb
|
363
396
|
- lib/datadog/profiling/ext/dir_monkey_patches.rb
|
364
|
-
- lib/datadog/profiling/ext/forking.rb
|
365
397
|
- lib/datadog/profiling/flush.rb
|
366
398
|
- lib/datadog/profiling/http_transport.rb
|
367
399
|
- lib/datadog/profiling/load_native_extension.rb
|
@@ -374,6 +406,7 @@ files:
|
|
374
406
|
- lib/datadog/profiling/tasks/exec.rb
|
375
407
|
- lib/datadog/profiling/tasks/help.rb
|
376
408
|
- lib/datadog/profiling/tasks/setup.rb
|
409
|
+
- lib/datadog/single_step_instrument.rb
|
377
410
|
- lib/datadog/tracing.rb
|
378
411
|
- lib/datadog/tracing/analytics.rb
|
379
412
|
- lib/datadog/tracing/buffer.rb
|
@@ -407,6 +440,8 @@ files:
|
|
407
440
|
- lib/datadog/tracing/contrib/action_mailer/patcher.rb
|
408
441
|
- lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb
|
409
442
|
- lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb
|
443
|
+
- lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb
|
444
|
+
- lib/datadog/tracing/contrib/action_pack/action_dispatch/patcher.rb
|
410
445
|
- lib/datadog/tracing/contrib/action_pack/configuration/settings.rb
|
411
446
|
- lib/datadog/tracing/contrib/action_pack/ext.rb
|
412
447
|
- lib/datadog/tracing/contrib/action_pack/integration.rb
|
@@ -807,7 +842,6 @@ files:
|
|
807
842
|
- lib/datadog/tracing/sampling/priority_sampler.rb
|
808
843
|
- lib/datadog/tracing/sampling/rate_by_key_sampler.rb
|
809
844
|
- lib/datadog/tracing/sampling/rate_by_service_sampler.rb
|
810
|
-
- lib/datadog/tracing/sampling/rate_limiter.rb
|
811
845
|
- lib/datadog/tracing/sampling/rate_sampler.rb
|
812
846
|
- lib/datadog/tracing/sampling/rule.rb
|
813
847
|
- lib/datadog/tracing/sampling/rule_sampler.rb
|
@@ -818,6 +852,7 @@ files:
|
|
818
852
|
- lib/datadog/tracing/sampling/span/rule_parser.rb
|
819
853
|
- lib/datadog/tracing/sampling/span/sampler.rb
|
820
854
|
- lib/datadog/tracing/span.rb
|
855
|
+
- lib/datadog/tracing/span_event.rb
|
821
856
|
- lib/datadog/tracing/span_link.rb
|
822
857
|
- lib/datadog/tracing/span_operation.rb
|
823
858
|
- lib/datadog/tracing/sync_writer.rb
|
@@ -852,8 +887,8 @@ licenses:
|
|
852
887
|
- Apache-2.0
|
853
888
|
metadata:
|
854
889
|
allowed_push_host: https://rubygems.org
|
855
|
-
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.
|
856
|
-
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.
|
890
|
+
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.4.0/CHANGELOG.md
|
891
|
+
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.4.0
|
857
892
|
post_install_message:
|
858
893
|
rdoc_options: []
|
859
894
|
require_paths:
|
@@ -872,7 +907,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
872
907
|
- !ruby/object:Gem::Version
|
873
908
|
version: 2.0.0
|
874
909
|
requirements: []
|
875
|
-
rubygems_version: 3.
|
910
|
+
rubygems_version: 3.5.17
|
876
911
|
signing_key:
|
877
912
|
specification_version: 4
|
878
913
|
summary: Datadog tracing code for your Ruby applications
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'libdatadog'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Profiling
|
7
|
-
# Used to report Ruby VM crashes.
|
8
|
-
# The interesting bits are implemented as native code and using libdatadog.
|
9
|
-
#
|
10
|
-
# NOTE: The crashtracker native state is a singleton; so even if you create multiple instances of `Crashtracker`
|
11
|
-
# and start them, it only works as "last writer wins". Same for stop -- there's only one state, so calling stop
|
12
|
-
# on it will stop the crash tracker, regardless of which instance started it.
|
13
|
-
#
|
14
|
-
# Methods prefixed with _native_ are implemented in `crashtracker.c`
|
15
|
-
class Crashtracker
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader \
|
19
|
-
:exporter_configuration,
|
20
|
-
:tags_as_array,
|
21
|
-
:path_to_crashtracking_receiver_binary,
|
22
|
-
:ld_library_path,
|
23
|
-
:upload_timeout_seconds
|
24
|
-
|
25
|
-
public
|
26
|
-
|
27
|
-
def initialize(
|
28
|
-
exporter_configuration:,
|
29
|
-
tags:,
|
30
|
-
upload_timeout_seconds:,
|
31
|
-
path_to_crashtracking_receiver_binary: Libdatadog.path_to_crashtracking_receiver_binary,
|
32
|
-
ld_library_path: Libdatadog.ld_library_path
|
33
|
-
)
|
34
|
-
@exporter_configuration = exporter_configuration
|
35
|
-
@tags_as_array = tags.to_a
|
36
|
-
@upload_timeout_seconds = upload_timeout_seconds
|
37
|
-
@path_to_crashtracking_receiver_binary = path_to_crashtracking_receiver_binary
|
38
|
-
@ld_library_path = ld_library_path
|
39
|
-
end
|
40
|
-
|
41
|
-
def start
|
42
|
-
start_or_update_on_fork(action: :start)
|
43
|
-
end
|
44
|
-
|
45
|
-
def reset_after_fork
|
46
|
-
start_or_update_on_fork(action: :update_on_fork)
|
47
|
-
end
|
48
|
-
|
49
|
-
def stop
|
50
|
-
begin
|
51
|
-
self.class._native_stop
|
52
|
-
Datadog.logger.debug('Crash tracking stopped successfully')
|
53
|
-
rescue => e
|
54
|
-
Datadog.logger.error("Failed to stop crash tracking: #{e.message}")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def start_or_update_on_fork(action:)
|
61
|
-
unless path_to_crashtracking_receiver_binary
|
62
|
-
Datadog.logger.warn(
|
63
|
-
"Cannot #{action} profiling crash tracking as no path_to_crashtracking_receiver_binary was found"
|
64
|
-
)
|
65
|
-
return
|
66
|
-
end
|
67
|
-
|
68
|
-
unless ld_library_path
|
69
|
-
Datadog.logger.warn(
|
70
|
-
"Cannot #{action} profiling crash tracking as no ld_library_path was found"
|
71
|
-
)
|
72
|
-
return
|
73
|
-
end
|
74
|
-
|
75
|
-
begin
|
76
|
-
self.class._native_start_or_update_on_fork(
|
77
|
-
action: action,
|
78
|
-
exporter_configuration: exporter_configuration,
|
79
|
-
path_to_crashtracking_receiver_binary: path_to_crashtracking_receiver_binary,
|
80
|
-
ld_library_path: ld_library_path,
|
81
|
-
tags_as_array: tags_as_array,
|
82
|
-
upload_timeout_seconds: Integer(upload_timeout_seconds),
|
83
|
-
)
|
84
|
-
Datadog.logger.debug("Crash tracking #{action} successful")
|
85
|
-
rescue => e
|
86
|
-
Datadog.logger.error("Failed to #{action} crash tracking: #{e.message}")
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Profiling
|
5
|
-
module Ext
|
6
|
-
# Monkey patches `Kernel#fork`, adding a `Kernel#at_fork` callback mechanism which is used to restore
|
7
|
-
# profiling abilities after the VM forks.
|
8
|
-
#
|
9
|
-
# Known limitations: Does not handle `BasicObject`s that include `Kernel` directly; e.g.
|
10
|
-
# `Class.new(BasicObject) { include(::Kernel); def call; fork { }; end }.new.call`.
|
11
|
-
#
|
12
|
-
# This will be fixed once we moved to hooking into `Process._fork`
|
13
|
-
module Forking
|
14
|
-
def self.supported?
|
15
|
-
Process.respond_to?(:fork)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.apply!
|
19
|
-
return false unless supported?
|
20
|
-
|
21
|
-
[
|
22
|
-
::Process.singleton_class, # Process.fork
|
23
|
-
::Kernel.singleton_class, # Kernel.fork
|
24
|
-
::Object, # fork without explicit receiver (it's defined as a method in ::Kernel)
|
25
|
-
# Note: Modifying Object as we do here is irreversible. During tests, this
|
26
|
-
# change will stick around even if we otherwise stub `Process` and `Kernel`
|
27
|
-
].each { |target| target.prepend(Kernel) }
|
28
|
-
|
29
|
-
::Process.singleton_class.prepend(ProcessDaemonPatch)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Extensions for kernel
|
33
|
-
#
|
34
|
-
# TODO: Consider hooking into `Process._fork` on Ruby 3.1+ instead, see
|
35
|
-
# https://github.com/ruby/ruby/pull/5017 and https://bugs.ruby-lang.org/issues/17795
|
36
|
-
module Kernel
|
37
|
-
def fork
|
38
|
-
# If a block is provided, it must be wrapped to trigger callbacks.
|
39
|
-
child_block = if block_given?
|
40
|
-
proc do
|
41
|
-
# Trigger :child callback
|
42
|
-
datadog_at_fork_blocks[:child].each(&:call) if datadog_at_fork_blocks.key?(:child)
|
43
|
-
|
44
|
-
# Invoke original block
|
45
|
-
yield
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Start fork
|
50
|
-
# If a block is provided, use the wrapped version.
|
51
|
-
result = child_block.nil? ? super : super(&child_block)
|
52
|
-
|
53
|
-
# Trigger correct callbacks depending on whether we're in the parent or child.
|
54
|
-
# If we're in the fork, result = nil: trigger child callbacks.
|
55
|
-
# If we're in the parent, result = fork PID: trigger parent callbacks.
|
56
|
-
datadog_at_fork_blocks[:child].each(&:call) if result.nil? && datadog_at_fork_blocks.key?(:child)
|
57
|
-
|
58
|
-
# Return PID from #fork
|
59
|
-
result
|
60
|
-
end
|
61
|
-
|
62
|
-
def at_fork(stage, &block)
|
63
|
-
raise ArgumentError, 'Bad \'stage\' for ::at_fork' unless stage == :child
|
64
|
-
|
65
|
-
datadog_at_fork_blocks[stage] = [] unless datadog_at_fork_blocks.key?(stage)
|
66
|
-
datadog_at_fork_blocks[stage] << block
|
67
|
-
end
|
68
|
-
|
69
|
-
module_function
|
70
|
-
|
71
|
-
def datadog_at_fork_blocks
|
72
|
-
# Blocks should be shared across all users of this module,
|
73
|
-
# e.g. Process#fork, Kernel#fork, etc. should all invoke the same callbacks.
|
74
|
-
# rubocop:disable Style/ClassVars
|
75
|
-
@@datadog_at_fork_blocks ||= {}
|
76
|
-
# rubocop:enable Style/ClassVars
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# A call to Process.daemon ( https://rubyapi.org/3.1/o/process#method-c-daemon ) forks the current process and
|
81
|
-
# keeps executing code in the child process, killing off the parent, thus effectively replacing it.
|
82
|
-
#
|
83
|
-
# This monkey patch makes the `Kernel#at_fork` mechanism defined above also work in this situation.
|
84
|
-
module ProcessDaemonPatch
|
85
|
-
def daemon(*args)
|
86
|
-
datadog_at_fork_blocks = Datadog::Profiling::Ext::Forking::Kernel.datadog_at_fork_blocks
|
87
|
-
|
88
|
-
result = super
|
89
|
-
|
90
|
-
datadog_at_fork_blocks[:child].each(&:call) if datadog_at_fork_blocks.key?(:child)
|
91
|
-
|
92
|
-
result
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|