datadog 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +51 -2
- data/ext/datadog_profiling_loader/extconf.rb +15 -15
- 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 +113 -43
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +49 -26
- 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 +49 -37
- data/ext/datadog_profiling_native_extension/collectors_stack.h +2 -2
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +81 -19
- data/ext/datadog_profiling_native_extension/collectors_thread_context.h +1 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.c +110 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +57 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +65 -60
- data/ext/datadog_profiling_native_extension/heap_recorder.c +34 -6
- 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 +3 -3
- 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 +64 -138
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +17 -11
- data/ext/datadog_profiling_native_extension/profiling.c +0 -2
- 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 +1 -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 +19 -6
- data/ext/libdatadog_api/datadog_ruby_common.c +110 -0
- data/ext/libdatadog_api/datadog_ruby_common.h +57 -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/contrib/graphql/appsec_trace.rb +49 -0
- data/lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb +73 -0
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +68 -0
- data/lib/datadog/appsec/contrib/graphql/integration.rb +41 -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 +1 -1
- data/lib/datadog/appsec/processor/actions.rb +1 -1
- data/lib/datadog/appsec/response.rb +15 -1
- data/lib/datadog/appsec.rb +1 -0
- data/lib/datadog/core/configuration/components.rb +14 -12
- data/lib/datadog/core/configuration/settings.rb +54 -7
- 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/telemetry/component.rb +49 -2
- data/lib/datadog/core/telemetry/emitter.rb +9 -11
- data/lib/datadog/core/telemetry/event.rb +32 -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/logging.rb +35 -0
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +102 -0
- data/lib/datadog/kit/appsec/events.rb +2 -4
- 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 +17 -17
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +11 -13
- data/lib/datadog/profiling/collectors/info.rb +3 -3
- data/lib/datadog/profiling/collectors/thread_context.rb +4 -2
- data/lib/datadog/profiling/component.rb +69 -91
- 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 +8 -6
- 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 +31 -25
- 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/tracing/contrib/active_record/events/sql.rb +1 -0
- data/lib/datadog/tracing/contrib/ext.rb +14 -0
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +1 -1
- data/lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb +4 -1
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +16 -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/pg/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +4 -1
- 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/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/metadata/errors.rb +9 -1
- data/lib/datadog/tracing/metadata/ext.rb +4 -0
- data/lib/datadog/tracing/pipeline/span_filter.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/transport/serializable_trace.rb +3 -0
- data/lib/datadog/version.rb +1 -1
- metadata +28 -10
- data/lib/datadog/profiling/crashtracker.rb +0 -91
- data/lib/datadog/profiling/ext/forking.rb +0 -98
@@ -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
|