datadog 2.1.0 → 2.2.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 +53 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +19 -1
- data/ext/datadog_profiling_native_extension/collectors_stack.c +41 -0
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +1 -1
- data/ext/datadog_profiling_native_extension/crashtracker.c +1 -1
- data/ext/datadog_profiling_native_extension/extconf.rb +6 -4
- data/ext/datadog_profiling_native_extension/native_extension_helpers.rb +47 -1
- data/ext/datadog_profiling_native_extension/setup_signal_handler.c +1 -1
- data/ext/datadog_profiling_native_extension/stack_recorder.c +13 -6
- data/ext/datadog_profiling_native_extension/stack_recorder.h +1 -0
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +1 -1
- data/lib/datadog/appsec/extensions.rb +1 -0
- data/lib/datadog/core/configuration/components.rb +6 -3
- data/lib/datadog/core/configuration/settings.rb +39 -0
- data/lib/datadog/core/configuration.rb +3 -17
- data/lib/datadog/core/deprecations.rb +58 -0
- data/lib/datadog/core/environment/yjit.rb +5 -0
- data/lib/datadog/core/runtime/ext.rb +1 -0
- data/lib/datadog/core/runtime/metrics.rb +6 -0
- data/lib/datadog/core/telemetry/component.rb +107 -0
- data/lib/datadog/core/telemetry/event.rb +100 -25
- data/lib/datadog/core/telemetry/ext.rb +2 -0
- data/lib/datadog/core/telemetry/http/adapters/net.rb +1 -1
- data/lib/datadog/core/telemetry/metric.rb +167 -0
- data/lib/datadog/core/telemetry/metrics_collection.rb +81 -0
- data/lib/datadog/core/telemetry/metrics_manager.rb +81 -0
- data/lib/datadog/core/telemetry/request.rb +1 -1
- data/lib/datadog/core/telemetry/worker.rb +173 -0
- data/lib/datadog/core/utils/only_once_successful.rb +76 -0
- data/lib/datadog/core.rb +2 -19
- data/lib/datadog/opentelemetry/sdk/propagator.rb +5 -10
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +5 -2
- data/lib/datadog/profiling/collectors/code_provenance.rb +18 -5
- data/lib/datadog/profiling/component.rb +18 -1
- data/lib/datadog/profiling/ext/dir_monkey_patches.rb +410 -0
- data/lib/datadog/profiling.rb +1 -0
- data/lib/datadog/tracing/contrib/action_cable/event.rb +1 -1
- data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +1 -1
- data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +1 -1
- data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +1 -1
- data/lib/datadog/tracing/contrib/action_mailer/event.rb +4 -6
- data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +9 -4
- data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +3 -2
- data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +1 -5
- 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_support/cache/event.rb +32 -0
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +156 -0
- data/lib/datadog/tracing/contrib/active_support/cache/events.rb +34 -0
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +45 -41
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +17 -40
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +4 -1
- data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +29 -6
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +16 -4
- data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +33 -29
- data/lib/datadog/tracing/contrib/analytics.rb +5 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/graphql/patcher.rb +8 -2
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +166 -0
- data/lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb +25 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +1 -1
- data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +1 -1
- data/lib/datadog/tracing/contrib/kafka/event.rb +1 -1
- data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +3 -3
- data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +3 -3
- data/lib/datadog/tracing/contrib/racecar/event.rb +2 -2
- data/lib/datadog/tracing/contrib/rails/ext.rb +9 -0
- data/lib/datadog/tracing/contrib/rails/patcher.rb +7 -0
- data/lib/datadog/tracing/contrib/rails/runner.rb +95 -0
- data/lib/datadog/tracing/distributed/b3_multi.rb +1 -1
- data/lib/datadog/tracing/distributed/b3_single.rb +3 -1
- data/lib/datadog/tracing/distributed/datadog.rb +2 -2
- data/lib/datadog/tracing/distributed/propagation.rb +9 -2
- data/lib/datadog/tracing/distributed/trace_context.rb +3 -2
- data/lib/datadog/tracing/span_operation.rb +3 -2
- data/lib/datadog/tracing/trace_operation.rb +7 -3
- data/lib/datadog/tracing/trace_segment.rb +4 -1
- data/lib/datadog/tracing/tracer.rb +9 -2
- data/lib/datadog/tracing.rb +5 -1
- data/lib/datadog/version.rb +2 -2
- metadata +22 -9
- data/lib/datadog/core/telemetry/client.rb +0 -95
- data/lib/datadog/core/telemetry/heartbeat.rb +0 -33
@@ -0,0 +1,410 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Profiling
|
5
|
+
# Monkey patches needed for profiler features and compatibility
|
6
|
+
module Ext
|
7
|
+
# All Ruby versions as of this writing have bugs in the dir class implementation, causing issues such as
|
8
|
+
# https://github.com/DataDog/dd-trace-rb/issues/3450 .
|
9
|
+
# See also https://bugs.ruby-lang.org/issues/20586 for more details.
|
10
|
+
#
|
11
|
+
# This monkey patch for the Ruby `Dir` class works around these bugs for affected Ruby versions by temporarily
|
12
|
+
# blocking the profiler from interrupting system calls.
|
13
|
+
#
|
14
|
+
# A lot of these APIs do very similar things -- they're provided by Ruby as helpers so users don't need to keep
|
15
|
+
# reimplementing them but share the same underlying buggy code. And so our monkey patches are a bit repetitive
|
16
|
+
# as well.
|
17
|
+
# We don't DRY out this file to have minimal overhead.
|
18
|
+
#
|
19
|
+
# These monkey patches are applied by the profiler when the "dir_interruption_workaround_enabled" setting is
|
20
|
+
# enabled. See the profiling settings for more detail.
|
21
|
+
module DirMonkeyPatches
|
22
|
+
def self.apply!
|
23
|
+
::Dir.singleton_class.prepend(Datadog::Profiling::Ext::DirClassMonkeyPatches)
|
24
|
+
::Dir.prepend(Datadog::Profiling::Ext::DirInstanceMonkeyPatches)
|
25
|
+
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if RUBY_VERSION.start_with?('2.')
|
31
|
+
# Monkey patches for Dir.singleton_class (Ruby 2 version). See DirMonkeyPatches above for more details.
|
32
|
+
module DirClassMonkeyPatches
|
33
|
+
def [](*args, &block)
|
34
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
35
|
+
super
|
36
|
+
ensure
|
37
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
38
|
+
end
|
39
|
+
|
40
|
+
def children(*args, &block)
|
41
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
42
|
+
super
|
43
|
+
ensure
|
44
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
45
|
+
end
|
46
|
+
|
47
|
+
# NOTE: When wrapping methods that yield, it's OK if the `yield` raises an exception while signals are
|
48
|
+
# enabled. This is because:
|
49
|
+
# * We can call `_native_resume_signals` many times in a row, both because it's idempotent, as well as it's
|
50
|
+
# very low overhead (see benchmarks/profiler_hold_resume_interruptions.rb)
|
51
|
+
# * When an exception is being raised, the iteration will stop anyway, so there's no longer a concern of a
|
52
|
+
# signal causing Ruby to return an incorrect value
|
53
|
+
def each_child(*args, &block)
|
54
|
+
if block
|
55
|
+
begin
|
56
|
+
# <-- Begin critical region
|
57
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
58
|
+
super do |entry_name|
|
59
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
60
|
+
# <-- We're safe now while running customer code
|
61
|
+
yield entry_name
|
62
|
+
# <-- We'll go back to the Dir internals, critical region again
|
63
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
64
|
+
end
|
65
|
+
ensure
|
66
|
+
# <-- End critical region
|
67
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
68
|
+
end
|
69
|
+
else
|
70
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
71
|
+
# other branch once it gets going.
|
72
|
+
super
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def empty?(*args, &block)
|
77
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
78
|
+
super
|
79
|
+
ensure
|
80
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
81
|
+
end
|
82
|
+
|
83
|
+
def entries(*args, &block)
|
84
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
85
|
+
super
|
86
|
+
ensure
|
87
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
88
|
+
end
|
89
|
+
|
90
|
+
# See note on methods that yield above.
|
91
|
+
def foreach(*args, &block)
|
92
|
+
if block
|
93
|
+
begin
|
94
|
+
# <-- Begin critical region
|
95
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
96
|
+
super do |entry_name|
|
97
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
98
|
+
# <-- We're safe now while running customer code
|
99
|
+
yield entry_name
|
100
|
+
# <-- We'll go back to the Dir internals, critical region again
|
101
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
102
|
+
end
|
103
|
+
ensure
|
104
|
+
# <-- End critical region
|
105
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
106
|
+
end
|
107
|
+
else
|
108
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
109
|
+
# other branch once it gets going.
|
110
|
+
super
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# See note on methods that yield above.
|
115
|
+
def glob(*args, &block)
|
116
|
+
if block
|
117
|
+
begin
|
118
|
+
# <-- Begin critical region
|
119
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
120
|
+
super do |entry_name|
|
121
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
122
|
+
# <-- We're safe now while running customer code
|
123
|
+
yield entry_name
|
124
|
+
# <-- We'll go back to the Dir internals, critical region again
|
125
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
126
|
+
end
|
127
|
+
ensure
|
128
|
+
# <-- End critical region
|
129
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
130
|
+
end
|
131
|
+
else
|
132
|
+
begin
|
133
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
134
|
+
super
|
135
|
+
ensure
|
136
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def home(*args, &block)
|
142
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
143
|
+
super
|
144
|
+
ensure
|
145
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
146
|
+
end
|
147
|
+
end
|
148
|
+
else
|
149
|
+
# Monkey patches for Dir.singleton_class (Ruby 3 version). See DirMonkeyPatches above for more details.
|
150
|
+
module DirClassMonkeyPatches
|
151
|
+
def [](*args, **kwargs, &block)
|
152
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
153
|
+
super
|
154
|
+
ensure
|
155
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
156
|
+
end
|
157
|
+
|
158
|
+
def children(*args, **kwargs, &block)
|
159
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
160
|
+
super
|
161
|
+
ensure
|
162
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
163
|
+
end
|
164
|
+
|
165
|
+
# See note on methods that yield above.
|
166
|
+
def each_child(*args, **kwargs, &block)
|
167
|
+
if block
|
168
|
+
begin
|
169
|
+
# <-- Begin critical region
|
170
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
171
|
+
super do |entry_name|
|
172
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
173
|
+
# <-- We're safe now while running customer code
|
174
|
+
yield entry_name
|
175
|
+
# <-- We'll go back to the Dir internals, critical region again
|
176
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
177
|
+
end
|
178
|
+
ensure
|
179
|
+
# <-- End critical region
|
180
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
181
|
+
end
|
182
|
+
else
|
183
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
184
|
+
# other branch once it gets going.
|
185
|
+
super
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def empty?(*args, **kwargs, &block)
|
190
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
191
|
+
super
|
192
|
+
ensure
|
193
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
194
|
+
end
|
195
|
+
|
196
|
+
def entries(*args, **kwargs, &block)
|
197
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
198
|
+
super
|
199
|
+
ensure
|
200
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
201
|
+
end
|
202
|
+
|
203
|
+
# See note on methods that yield above.
|
204
|
+
def foreach(*args, **kwargs, &block)
|
205
|
+
if block
|
206
|
+
begin
|
207
|
+
# <-- Begin critical region
|
208
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
209
|
+
super do |entry_name|
|
210
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
211
|
+
# <-- We're safe now while running customer code
|
212
|
+
yield entry_name
|
213
|
+
# <-- We'll go back to the Dir internals, critical region again
|
214
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
215
|
+
end
|
216
|
+
ensure
|
217
|
+
# <-- End critical region
|
218
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
219
|
+
end
|
220
|
+
else
|
221
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
222
|
+
# other branch once it gets going.
|
223
|
+
super
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# See note on methods that yield above.
|
228
|
+
def glob(*args, **kwargs, &block)
|
229
|
+
if block
|
230
|
+
begin
|
231
|
+
# <-- Begin critical region
|
232
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
233
|
+
super do |entry_name|
|
234
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
235
|
+
# <-- We're safe now while running customer code
|
236
|
+
yield entry_name
|
237
|
+
# <-- We'll go back to the Dir internals, critical region again
|
238
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
239
|
+
end
|
240
|
+
ensure
|
241
|
+
# <-- End critical region
|
242
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
243
|
+
end
|
244
|
+
else
|
245
|
+
begin
|
246
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
247
|
+
super
|
248
|
+
ensure
|
249
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def home(*args, **kwargs, &block)
|
255
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
256
|
+
super
|
257
|
+
ensure
|
258
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
if RUBY_VERSION.start_with?('2.')
|
264
|
+
# Monkey patches for Dir (Ruby 2 version). See DirMonkeyPatches above for more details.
|
265
|
+
module DirInstanceMonkeyPatches
|
266
|
+
# See note on methods that yield above.
|
267
|
+
def each(*args, &block)
|
268
|
+
if block
|
269
|
+
begin
|
270
|
+
# <-- Begin critical region
|
271
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
272
|
+
super do |entry_name|
|
273
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
274
|
+
# <-- We're safe now while running customer code
|
275
|
+
yield entry_name
|
276
|
+
# <-- We'll go back to the Dir internals, critical region again
|
277
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
278
|
+
end
|
279
|
+
ensure
|
280
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals # <-- End critical region
|
281
|
+
end
|
282
|
+
else
|
283
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
284
|
+
# other branch once it gets going.
|
285
|
+
super
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
unless RUBY_VERSION.start_with?('2.5.') # This is Ruby 2.6+
|
290
|
+
# See note on methods that yield above.
|
291
|
+
def each_child(*args, &block)
|
292
|
+
if block
|
293
|
+
begin
|
294
|
+
# <-- Begin critical region
|
295
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
296
|
+
super do |entry_name|
|
297
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
298
|
+
# <-- We're safe now while running customer code
|
299
|
+
yield entry_name
|
300
|
+
# <-- We'll go back to the Dir internals, critical region again
|
301
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
302
|
+
end
|
303
|
+
ensure
|
304
|
+
# <-- End critical region
|
305
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
306
|
+
end
|
307
|
+
else
|
308
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
309
|
+
# other branch once it gets going.
|
310
|
+
super
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
def children(*args, &block)
|
315
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
316
|
+
super
|
317
|
+
ensure
|
318
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
def tell(*args, &block)
|
323
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
324
|
+
super
|
325
|
+
ensure
|
326
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
327
|
+
end
|
328
|
+
|
329
|
+
def pos(*args, &block)
|
330
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
331
|
+
super
|
332
|
+
ensure
|
333
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
334
|
+
end
|
335
|
+
end
|
336
|
+
else
|
337
|
+
# Monkey patches for Dir (Ruby 3 version). See DirMonkeyPatches above for more details.
|
338
|
+
module DirInstanceMonkeyPatches
|
339
|
+
# See note on methods that yield above.
|
340
|
+
def each(*args, **kwargs, &block)
|
341
|
+
if block
|
342
|
+
begin
|
343
|
+
# <-- Begin critical region
|
344
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
345
|
+
super do |entry_name|
|
346
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
347
|
+
# <-- We're safe now while running customer code
|
348
|
+
yield entry_name
|
349
|
+
# <-- We'll go back to the Dir internals, critical region again
|
350
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
351
|
+
end
|
352
|
+
ensure
|
353
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals # <-- End critical region
|
354
|
+
end
|
355
|
+
else
|
356
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
357
|
+
# other branch once it gets going.
|
358
|
+
super
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
# See note on methods that yield above.
|
363
|
+
def each_child(*args, **kwargs, &block)
|
364
|
+
if block
|
365
|
+
begin
|
366
|
+
# <-- Begin critical region
|
367
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
368
|
+
super do |entry_name|
|
369
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
370
|
+
# <-- We're safe now while running customer code
|
371
|
+
yield entry_name
|
372
|
+
# <-- We'll go back to the Dir internals, critical region again
|
373
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
374
|
+
end
|
375
|
+
ensure
|
376
|
+
# <-- End critical region
|
377
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
378
|
+
end
|
379
|
+
else
|
380
|
+
# This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
|
381
|
+
# other branch once it gets going.
|
382
|
+
super
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
def children(*args, **kwargs, &block)
|
387
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
388
|
+
super
|
389
|
+
ensure
|
390
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
391
|
+
end
|
392
|
+
|
393
|
+
def tell(*args, **kwargs, &block)
|
394
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
395
|
+
super
|
396
|
+
ensure
|
397
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
398
|
+
end
|
399
|
+
|
400
|
+
def pos(*args, **kwargs, &block)
|
401
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
402
|
+
super
|
403
|
+
ensure
|
404
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
data/lib/datadog/profiling.rb
CHANGED
@@ -136,6 +136,7 @@ module Datadog
|
|
136
136
|
return false unless supported?
|
137
137
|
|
138
138
|
require_relative 'profiling/ext/forking'
|
139
|
+
require_relative 'profiling/ext/dir_monkey_patches'
|
139
140
|
require_relative 'profiling/collectors/info'
|
140
141
|
require_relative 'profiling/collectors/code_provenance'
|
141
142
|
require_relative 'profiling/collectors/cpu_and_wall_time_worker'
|
@@ -34,7 +34,7 @@ module Datadog
|
|
34
34
|
Tracing::Metadata::Ext::AppTypes::TYPE_WEB
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def on_start(span, _event, _id, payload)
|
38
38
|
channel = payload[:broadcasting] # Channel has high cardinality
|
39
39
|
span.service = configuration[:service_name] if configuration[:service_name]
|
40
40
|
span.type = span_type
|
@@ -33,7 +33,7 @@ module Datadog
|
|
33
33
|
Tracing::Metadata::Ext::AppTypes::TYPE_WEB
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def on_start(span, _event, _id, payload)
|
37
37
|
channel_class = payload[:channel_class]
|
38
38
|
|
39
39
|
span.service = configuration[:service_name] if configuration[:service_name]
|
@@ -27,9 +27,11 @@ module Datadog
|
|
27
27
|
Datadog.configuration.tracing[:action_mailer]
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def on_start(span, event, _id, payload)
|
31
|
+
super
|
32
|
+
|
33
|
+
span.type = span_type
|
31
34
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
|
-
span.resource = payload[:mailer]
|
33
35
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
34
36
|
|
35
37
|
# Set analytics sample rate
|
@@ -39,10 +41,6 @@ module Datadog
|
|
39
41
|
|
40
42
|
# Measure service stats
|
41
43
|
Contrib::Analytics.set_measured(span)
|
42
|
-
|
43
|
-
report_if_exception(span, payload)
|
44
|
-
rescue StandardError => e
|
45
|
-
Datadog.logger.debug(e.message)
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
@@ -30,15 +30,20 @@ module Datadog
|
|
30
30
|
Tracing::Metadata::Ext::AppTypes::TYPE_WORKER
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def on_start(span, event, _id, payload)
|
34
34
|
super
|
35
35
|
|
36
|
-
span.
|
36
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_DELIVER)
|
37
|
+
end
|
38
|
+
|
39
|
+
def on_finish(span, event, _id, payload)
|
40
|
+
super
|
41
|
+
|
42
|
+
span.resource = payload[:mailer] # Mailer is not available at `on_start`
|
43
|
+
|
37
44
|
span.set_tag(Ext::TAG_MAILER, payload[:mailer])
|
38
45
|
span.set_tag(Ext::TAG_MSG_ID, payload[:message_id])
|
39
46
|
|
40
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_DELIVER)
|
41
|
-
|
42
47
|
# Since email data can contain PII we disable by default
|
43
48
|
# Some of these fields can be either strings or arrays, so we try to normalize
|
44
49
|
# https://github.com/rails/rails/blob/18707ab17fa492eb25ad2e8f9818a320dc20b823/actionmailer/lib/action_mailer/base.rb#L742-L754
|
@@ -30,10 +30,11 @@ module Datadog
|
|
30
30
|
Tracing::Metadata::Ext::HTTP::TYPE_TEMPLATE
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def on_start(span, event, _id, payload)
|
34
34
|
super
|
35
35
|
|
36
|
-
span.
|
36
|
+
span.resource = payload[:mailer] # Mailer is not available at `on_start`
|
37
|
+
|
37
38
|
span.set_tag(Ext::TAG_ACTION, payload[:action])
|
38
39
|
span.set_tag(Ext::TAG_MAILER, payload[:mailer])
|
39
40
|
|
@@ -27,7 +27,7 @@ module Datadog
|
|
27
27
|
Ext::SPAN_RENDER_PARTIAL
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def on_start(span, _event, _id, payload)
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.type = Tracing::Metadata::Ext::HTTP::TYPE_TEMPLATE
|
33
33
|
|
@@ -41,10 +41,6 @@ module Datadog
|
|
41
41
|
|
42
42
|
# Measure service stats
|
43
43
|
Contrib::Analytics.set_measured(span)
|
44
|
-
|
45
|
-
record_exception(span, payload)
|
46
|
-
rescue StandardError => e
|
47
|
-
Datadog.logger.debug(e.message)
|
48
44
|
end
|
49
45
|
end
|
50
46
|
end
|
@@ -27,7 +27,7 @@ module Datadog
|
|
27
27
|
Ext::SPAN_RENDER_TEMPLATE
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def on_start(span, _event, _id, payload)
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.type = Tracing::Metadata::Ext::HTTP::TYPE_TEMPLATE
|
33
33
|
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
Ext::SPAN_DISCARD
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def on_start(span, event, _id, payload)
|
30
30
|
span.name = span_name
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.resource = payload[:job].class.name
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
Ext::SPAN_ENQUEUE
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def on_start(span, event, _id, payload)
|
30
30
|
span.name = span_name
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.resource = payload[:job].class.name
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
Ext::SPAN_ENQUEUE
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def on_start(span, event, _id, payload)
|
30
30
|
span.name = span_name
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.resource = payload[:job].class.name
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
Ext::SPAN_ENQUEUE_RETRY
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def on_start(span, event, _id, payload)
|
30
30
|
span.name = span_name
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.resource = payload[:job].class.name
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
Ext::SPAN_PERFORM
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def on_start(span, event, _id, payload)
|
30
30
|
span.name = span_name
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.resource = payload[:job].class.name
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
Ext::SPAN_RETRY_STOPPED
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def on_start(span, event, _id, payload)
|
30
30
|
span.name = span_name
|
31
31
|
span.service = configuration[:service_name] if configuration[:service_name]
|
32
32
|
span.resource = payload[:job].class.name
|
@@ -31,7 +31,7 @@ module Datadog
|
|
31
31
|
Ext::SPAN_INSTANTIATION
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def on_start(span, event, _id, payload)
|
35
35
|
span.resource = payload.fetch(:class_name)
|
36
36
|
span.type = Ext::SPAN_TYPE_INSTANTIATION
|
37
37
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
@@ -29,7 +29,7 @@ module Datadog
|
|
29
29
|
Ext::SPAN_SQL
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def on_start(span, event, _id, payload)
|
33
33
|
config = Utils.connection_config(payload[:connection], payload[:connection_id])
|
34
34
|
settings = Datadog.configuration.tracing[:active_record, config]
|
35
35
|
adapter_name = Contrib::Utils::Database.normalize_vendor(config[:adapter])
|