ddtrace 1.19.0 → 1.21.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 +93 -2
- data/LICENSE-3rdparty.csv +1 -1
- data/bin/ddprofrb +15 -0
- data/bin/ddtracerb +3 -1
- data/ext/{ddtrace_profiling_loader/ddtrace_profiling_loader.c → datadog_profiling_loader/datadog_profiling_loader.c} +2 -2
- data/ext/{ddtrace_profiling_loader → datadog_profiling_loader}/extconf.rb +3 -3
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_cpu_and_wall_time_worker.c +237 -65
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +422 -0
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +101 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_thread_context.c +92 -2
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/extconf.rb +5 -2
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/helpers.h +4 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/http_transport.c +10 -14
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/native_extension_helpers.rb +4 -4
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/private_vm_api_access.c +14 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/private_vm_api_access.h +4 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/profiling.c +17 -1
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/ruby_helpers.c +10 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/ruby_helpers.h +2 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/time_helpers.h +2 -0
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +2 -1
- data/lib/datadog/core/configuration/components.rb +5 -5
- data/lib/datadog/core/configuration/option.rb +1 -1
- data/lib/datadog/core/configuration/settings.rb +107 -46
- data/lib/datadog/core/diagnostics/environment_logger.rb +4 -3
- data/lib/datadog/core/environment/class_count.rb +6 -6
- data/lib/datadog/core/environment/git.rb +25 -0
- data/lib/datadog/core/environment/identity.rb +18 -48
- data/lib/datadog/core/git/ext.rb +2 -23
- data/lib/datadog/core/remote/component.rb +25 -12
- data/lib/datadog/core/remote/ext.rb +1 -0
- data/lib/datadog/core/remote/negotiation.rb +2 -2
- data/lib/datadog/core/remote/tie/tracing.rb +39 -0
- data/lib/datadog/core/remote/tie.rb +27 -0
- data/lib/datadog/core/remote/worker.rb +7 -4
- data/lib/datadog/core/transport/ext.rb +2 -0
- data/lib/datadog/core/utils/url.rb +25 -0
- data/lib/datadog/opentelemetry/sdk/propagator.rb +3 -2
- data/lib/datadog/opentelemetry.rb +3 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +6 -2
- data/lib/datadog/profiling/collectors/info.rb +101 -0
- data/lib/datadog/profiling/component.rb +14 -30
- data/lib/datadog/profiling/exporter.rb +19 -5
- data/lib/datadog/profiling/ext.rb +2 -0
- data/lib/datadog/profiling/flush.rb +6 -3
- data/lib/datadog/profiling/http_transport.rb +5 -1
- data/lib/datadog/profiling/load_native_extension.rb +5 -5
- data/lib/datadog/profiling/native_extension.rb +1 -1
- data/lib/datadog/profiling/tag_builder.rb +5 -0
- data/lib/datadog/profiling/tasks/exec.rb +3 -3
- data/lib/datadog/profiling/tasks/help.rb +3 -3
- data/lib/datadog/profiling.rb +2 -2
- data/lib/datadog/tracing/configuration/ext.rb +0 -1
- data/lib/datadog/tracing/configuration/settings.rb +2 -1
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/action_cable/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/action_mailer/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/action_view/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/active_job/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/active_record/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/active_support/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/analytics.rb +0 -1
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/aws/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/async_patch.rb +20 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +11 -1
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/dalli/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/delayed_job/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/ethon/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/excon/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/extensions.rb +6 -2
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +7 -0
- data/lib/datadog/tracing/contrib/faraday/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +1 -1
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +5 -0
- data/lib/datadog/tracing/contrib/grape/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/graphql/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +2 -2
- data/lib/datadog/tracing/contrib/http/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/httprb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/kafka/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/pg/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +11 -4
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/presto/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/qless/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/que/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/racecar/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/rack/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +37 -6
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/rails/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/rails/patcher.rb +16 -0
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/rake/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/redis/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +2 -2
- data/lib/datadog/tracing/contrib/redis/patcher.rb +34 -21
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/resque/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/roda/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/sequel/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/shoryuken/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/sinatra/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer.rb +6 -3
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/sneakers/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/stripe/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +58 -0
- data/lib/datadog/tracing/contrib/trilogy/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +94 -0
- data/lib/datadog/tracing/contrib/trilogy/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/trilogy/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/metadata/ext.rb +2 -0
- data/lib/datadog/tracing/trace_operation.rb +1 -2
- data/lib/datadog/tracing/transport/http.rb +1 -0
- data/lib/datadog/tracing/transport/trace_formatter.rb +31 -0
- data/lib/datadog/tracing.rb +8 -2
- data/lib/ddtrace/version.rb +1 -1
- metadata +62 -50
- data/ext/ddtrace_profiling_native_extension/pid_controller.c +0 -57
- data/ext/ddtrace_profiling_native_extension/pid_controller.h +0 -45
- data/lib/datadog/profiling/diagnostics/environment_logger.rb +0 -39
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/NativeExtensionDesign.md +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id_from_pthread.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id_noop.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_dynamic_sampling_rate.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_dynamic_sampling_rate.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_gc_profiling_helper.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_gc_profiling_helper.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_idle_sampling_helper.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_idle_sampling_helper.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_stack.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_stack.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_thread_context.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/heap_recorder.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/heap_recorder.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/libdatadog_helpers.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/libdatadog_helpers.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/setup_signal_handler.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/setup_signal_handler.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/stack_recorder.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/stack_recorder.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/time_helpers.c +0 -0
@@ -205,6 +205,22 @@ module Datadog
|
|
205
205
|
option :transport
|
206
206
|
end
|
207
207
|
|
208
|
+
# Can be used to enable/disable collection of allocation profiles.
|
209
|
+
#
|
210
|
+
# This feature is disabled by default
|
211
|
+
#
|
212
|
+
# @warn Due to bugs in Ruby we only recommend enabling this feature in
|
213
|
+
# Ruby versions 2.x, 3.1.4+, 3.2.3+ and 3.3.0+
|
214
|
+
# (more details in {Datadog::Profiling::Component.enable_allocation_profiling?})
|
215
|
+
#
|
216
|
+
# @default `DD_PROFILING_ALLOCATION_ENABLED` environment variable as a boolean, otherwise `false`
|
217
|
+
option :allocation_enabled do |o|
|
218
|
+
o.type :bool
|
219
|
+
o.deprecated_env 'DD_PROFILING_EXPERIMENTAL_ALLOCATION_ENABLED' # TODO: Remove this for dd-trace-rb 2.0
|
220
|
+
o.env 'DD_PROFILING_ALLOCATION_ENABLED'
|
221
|
+
o.default false
|
222
|
+
end
|
223
|
+
|
208
224
|
# @public_api
|
209
225
|
settings :advanced do
|
210
226
|
# @deprecated No longer does anything, and will be removed on dd-trace-rb 2.0.
|
@@ -212,11 +228,13 @@ module Datadog
|
|
212
228
|
# This was used prior to the GA of the new CPU Profiling 2.0 profiler. The CPU Profiling 2.0 profiler does not
|
213
229
|
# use or need this setting and thus it doesn't do anything.
|
214
230
|
option :max_events do |o|
|
215
|
-
o.after_set do
|
216
|
-
Datadog
|
217
|
-
|
218
|
-
|
219
|
-
|
231
|
+
o.after_set do |_, _, precedence|
|
232
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
233
|
+
Datadog.logger.warn(
|
234
|
+
'The profiling.advanced.max_events setting has been deprecated for removal and no ' \
|
235
|
+
'longer does anything. Please remove it from your Datadog.configure block.'
|
236
|
+
)
|
237
|
+
end
|
220
238
|
end
|
221
239
|
end
|
222
240
|
|
@@ -255,11 +273,13 @@ module Datadog
|
|
255
273
|
# This was added as a temporary support option in case of issues with the new `Profiling::HttpTransport` class
|
256
274
|
# but we're now confident it's working nicely so we've removed the old code path.
|
257
275
|
option :legacy_transport_enabled do |o|
|
258
|
-
o.after_set do
|
259
|
-
Datadog
|
260
|
-
|
261
|
-
|
262
|
-
|
276
|
+
o.after_set do |_, _, precedence|
|
277
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
278
|
+
Datadog.logger.warn(
|
279
|
+
'The profiling.advanced.legacy_transport_enabled setting has been deprecated for removal and no ' \
|
280
|
+
'longer does anything. Please remove it from your Datadog.configure block.'
|
281
|
+
)
|
282
|
+
end
|
263
283
|
end
|
264
284
|
end
|
265
285
|
|
@@ -268,11 +288,13 @@ module Datadog
|
|
268
288
|
# This was used prior to the GA of the new CPU Profiling 2.0 profiler. Using CPU Profiling 2.0 is now the
|
269
289
|
# default and this doesn't do anything.
|
270
290
|
option :force_enable_new_profiler do |o|
|
271
|
-
o.after_set do
|
272
|
-
Datadog
|
273
|
-
|
274
|
-
|
275
|
-
|
291
|
+
o.after_set do |_, _, precedence|
|
292
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
293
|
+
Datadog.logger.warn(
|
294
|
+
'The profiling.advanced.force_enable_new_profiler setting has been deprecated for removal and no ' \
|
295
|
+
'longer does anything. Please remove it from your Datadog.configure block.'
|
296
|
+
)
|
297
|
+
end
|
276
298
|
end
|
277
299
|
end
|
278
300
|
|
@@ -281,11 +303,13 @@ module Datadog
|
|
281
303
|
# This was used prior to the GA of the new CPU Profiling 2.0 profiler. Using CPU Profiling 2.0 is now the
|
282
304
|
# default and this doesn't do anything.
|
283
305
|
option :force_enable_legacy_profiler do |o|
|
284
|
-
o.after_set do
|
285
|
-
Datadog
|
286
|
-
|
287
|
-
|
288
|
-
|
306
|
+
o.after_set do |_, _, precedence|
|
307
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
308
|
+
Datadog.logger.warn(
|
309
|
+
'The profiling.advanced.force_enable_legacy_profiler setting has been deprecated for removal and no ' \
|
310
|
+
'longer does anything. Please remove it from your Datadog.configure block.'
|
311
|
+
)
|
312
|
+
end
|
289
313
|
end
|
290
314
|
end
|
291
315
|
|
@@ -314,30 +338,32 @@ module Datadog
|
|
314
338
|
|
315
339
|
# Can be used to enable/disable the Datadog::Profiling.allocation_count feature.
|
316
340
|
#
|
317
|
-
#
|
341
|
+
# @deprecated Use {:allocation_enabled} (outside of advanced section) instead.
|
318
342
|
option :allocation_counting_enabled do |o|
|
319
|
-
o.after_set do
|
320
|
-
Datadog
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
343
|
+
o.after_set do |_, _, precedence|
|
344
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
345
|
+
Datadog.logger.warn(
|
346
|
+
'The profiling.advanced.allocation_counting_enabled setting has been deprecated for removal and no ' \
|
347
|
+
'longer does anything. Please remove it from your Datadog.configure block. ' \
|
348
|
+
'Allocation counting is now controlled by the profiling.allocation_enabled setting instead.'
|
349
|
+
)
|
350
|
+
end
|
325
351
|
end
|
326
352
|
end
|
327
353
|
|
328
|
-
#
|
329
|
-
#
|
330
|
-
# This feature is alpha and disabled by default
|
331
|
-
#
|
332
|
-
# @warn This feature is not supported/safe in all Rubies. Details in {Datadog::Profiling::Component} but
|
333
|
-
# in summary, this should be supported on Ruby 2.x, 3.1.4+, 3.2.3+ and 3.3.0+. Enabling it on
|
334
|
-
# unsupported Rubies may result in unexpected behaviour, including crashes.
|
335
|
-
#
|
336
|
-
# @default `DD_PROFILING_EXPERIMENTAL_ALLOCATION_ENABLED` environment variable as a boolean, otherwise `false`
|
354
|
+
# @deprecated Use {:allocation_enabled} (outside of advanced section) instead.
|
337
355
|
option :experimental_allocation_enabled do |o|
|
338
356
|
o.type :bool
|
339
|
-
o.env 'DD_PROFILING_EXPERIMENTAL_ALLOCATION_ENABLED'
|
340
357
|
o.default false
|
358
|
+
o.after_set do |_, _, precedence|
|
359
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
360
|
+
Datadog.logger.warn(
|
361
|
+
'The profiling.advanced.experimental_allocation_enabled setting has been deprecated for removal and ' \
|
362
|
+
'no longer does anything. Please remove it from your Datadog.configure block. ' \
|
363
|
+
'Allocation profiling is now controlled by the profiling.allocation_enabled setting instead.'
|
364
|
+
)
|
365
|
+
end
|
366
|
+
end
|
341
367
|
end
|
342
368
|
|
343
369
|
# Can be used to enable/disable the collection of heap profiles.
|
@@ -369,14 +395,18 @@ module Datadog
|
|
369
395
|
|
370
396
|
# Can be used to configure the allocation sampling rate: a sample will be collected every x allocations.
|
371
397
|
#
|
372
|
-
#
|
373
|
-
# particular, a value of 1 will sample ALL allocations.
|
374
|
-
#
|
375
|
-
# @default `DD_PROFILING_EXPERIMENTAL_ALLOCATION_SAMPLE_RATE` environment variable, otherwise `50`.
|
398
|
+
# This feature is now controlled via {:overhead_target_percentage}
|
376
399
|
option :experimental_allocation_sample_rate do |o|
|
377
|
-
o.
|
378
|
-
|
379
|
-
|
400
|
+
o.after_set do |_, _, precedence|
|
401
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
402
|
+
Datadog.logger.warn(
|
403
|
+
'The profiling.advanced.experimental_allocation_sample_rate setting has been deprecated for removal ' \
|
404
|
+
'and no longer does anything. Please remove it from your Datadog.configure block. ' \
|
405
|
+
'Allocation sample rate is now handled by a dynamic sampler which will adjust the sampling rate to ' \
|
406
|
+
'keep to the configured `profiling.advanced.overhead_target_percentage`.'
|
407
|
+
)
|
408
|
+
end
|
409
|
+
end
|
380
410
|
end
|
381
411
|
|
382
412
|
# Can be used to configure the heap sampling rate: a heap sample will be collected for every x allocation
|
@@ -410,9 +440,27 @@ module Datadog
|
|
410
440
|
#
|
411
441
|
# @default `DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED` environment variable as a boolean, otherwise `false`
|
412
442
|
option :experimental_timeline_enabled do |o|
|
443
|
+
o.after_set do |_, _, precedence|
|
444
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
445
|
+
Datadog.logger.warn(
|
446
|
+
'The profiling.advanced.experimental_timeline_enabled setting has been deprecated for removal ' \
|
447
|
+
'and no longer does anything. Please remove it from your Datadog.configure block. ' \
|
448
|
+
'The timeline feature counting is now controlled by the `timeline_enabled` setting instead.'
|
449
|
+
)
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
# Controls data collection for the timeline feature.
|
455
|
+
#
|
456
|
+
# If you needed to disable this, please tell us why on <https://github.com/DataDog/dd-trace-rb/issues/new>,
|
457
|
+
# so we can fix it!
|
458
|
+
#
|
459
|
+
# @default `DD_PROFILING_TIMELINE_ENABLED` environment variable as a boolean, otherwise `true`
|
460
|
+
option :timeline_enabled do |o|
|
413
461
|
o.type :bool
|
414
|
-
o.env '
|
415
|
-
o.default
|
462
|
+
o.env 'DD_PROFILING_TIMELINE_ENABLED'
|
463
|
+
o.default true
|
416
464
|
end
|
417
465
|
|
418
466
|
# The profiler gathers data by sending `SIGPROF` unix signals to Ruby application threads.
|
@@ -747,6 +795,19 @@ module Datadog
|
|
747
795
|
o.default 5.0
|
748
796
|
end
|
749
797
|
|
798
|
+
# Tune remote configuration boot timeout.
|
799
|
+
# Early operations such as requests are blocked until RC is ready. In
|
800
|
+
# order to not block the application indefinitely a timeout is
|
801
|
+
# enforced allowing requests to proceed with the local configuration.
|
802
|
+
#
|
803
|
+
# @default `DD_REMOTE_CONFIG_BOOT_TIMEOUT` environment variable, otherwise `1.0` seconds.
|
804
|
+
# @return [Float]
|
805
|
+
option :boot_timeout_seconds do |o|
|
806
|
+
o.env Core::Remote::Ext::ENV_BOOT_TIMEOUT_SECONDS
|
807
|
+
o.type :float
|
808
|
+
o.default 1.0
|
809
|
+
end
|
810
|
+
|
750
811
|
# Declare service name to bind to remote configuration. Use when
|
751
812
|
# DD_SERVICE does not match the correct integration for which remote
|
752
813
|
# configuration applies.
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'date'
|
4
3
|
require 'json'
|
5
4
|
require 'rbconfig'
|
5
|
+
require 'time'
|
6
6
|
|
7
7
|
module Datadog
|
8
8
|
module Core
|
@@ -58,9 +58,10 @@ module Datadog
|
|
58
58
|
module EnvironmentLogger
|
59
59
|
extend EnvironmentLogging
|
60
60
|
|
61
|
-
def self.collect_and_log!
|
61
|
+
def self.collect_and_log!(extra_fields = nil)
|
62
62
|
log_once! do
|
63
63
|
data = EnvironmentCollector.collect_config!
|
64
|
+
data = data.merge(extra_fields) if extra_fields
|
64
65
|
log_configuration!('CORE', data.to_json)
|
65
66
|
end
|
66
67
|
rescue => e
|
@@ -91,7 +92,7 @@ module Datadog
|
|
91
92
|
|
92
93
|
# @return [String] current time in ISO8601 format
|
93
94
|
def date
|
94
|
-
|
95
|
+
Time.now.utc.iso8601
|
95
96
|
end
|
96
97
|
|
97
98
|
# Best portable guess of OS information.
|
@@ -5,15 +5,15 @@ module Datadog
|
|
5
5
|
module Environment
|
6
6
|
# Retrieves number of classes from runtime
|
7
7
|
module ClassCount
|
8
|
-
|
9
|
-
|
10
|
-
def value
|
8
|
+
def self.value
|
11
9
|
::ObjectSpace.count_objects[:T_CLASS]
|
12
10
|
end
|
13
11
|
|
14
|
-
def available?
|
15
|
-
|
16
|
-
|
12
|
+
def self.available?
|
13
|
+
return @class_count_available if defined?(@class_count_available)
|
14
|
+
|
15
|
+
@class_count_available =
|
16
|
+
::ObjectSpace.respond_to?(:count_objects) && ::ObjectSpace.count_objects.key?(:T_CLASS)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../git/ext'
|
4
|
+
require_relative '../utils/url'
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module Core
|
8
|
+
module Environment
|
9
|
+
# Retrieves git repository information from environment variables
|
10
|
+
module Git
|
11
|
+
def self.git_repository_url
|
12
|
+
return @git_repository_url if defined?(@git_repository_url)
|
13
|
+
|
14
|
+
@git_repository_url = Utils::Url.filter_basic_auth(ENV[Datadog::Core::Git::Ext::ENV_REPOSITORY_URL])
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.git_commit_sha
|
18
|
+
return @git_commit_sha if defined?(@git_commit_sha)
|
19
|
+
|
20
|
+
@git_commit_sha = ENV[Datadog::Core::Git::Ext::ENV_COMMIT_SHA]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -56,58 +56,28 @@ module Datadog
|
|
56
56
|
|
57
57
|
# Returns tracer version, comforming to https://semver.org/spec/v2.0.0.html
|
58
58
|
def tracer_version_semver2
|
59
|
-
|
60
|
-
# - transform .PRE to -PRE if present
|
61
|
-
# - transform .BUILD to +BUILD if present
|
62
|
-
# - keep triplet segments before that
|
59
|
+
major, minor, patch, rest = tracer_version.split('.', 4)
|
63
60
|
|
64
|
-
|
61
|
+
semver = "#{major}.#{minor}.#{patch}"
|
65
62
|
|
66
|
-
|
67
|
-
build = "+gha#{m[:gha_run_id]}.g#{m[:git_sha]}.#{m[:branch].tr('.', '-')}" if m[:build]
|
63
|
+
return semver unless rest
|
68
64
|
|
69
|
-
|
70
|
-
|
65
|
+
pre = ''
|
66
|
+
build = ''
|
67
|
+
|
68
|
+
rest.split('.').tap do |segments|
|
69
|
+
if segments.length >= 4
|
70
|
+
pre = "-#{segments.shift}"
|
71
|
+
build = "+#{segments.join('.')}"
|
72
|
+
elsif segments.length == 1
|
73
|
+
pre = "-#{segments.shift}"
|
74
|
+
else
|
75
|
+
build = "+#{segments.join('.')}"
|
76
|
+
end
|
77
|
+
end
|
71
78
|
|
72
|
-
|
73
|
-
|
74
|
-
# mandatory segments
|
75
|
-
(?<major>\d+)
|
76
|
-
\.
|
77
|
-
(?<minor>\d+)
|
78
|
-
\.
|
79
|
-
(?<patch>\d+)
|
80
|
-
|
81
|
-
# pre segments start with a value
|
82
|
-
# - containing at least one alpha
|
83
|
-
# - that is not part of our build segments expected values
|
84
|
-
# and stop with a value that is not part of our build segments expected values
|
85
|
-
(?:
|
86
|
-
\.
|
87
|
-
(?<pre>
|
88
|
-
(?!gha)
|
89
|
-
[a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*
|
90
|
-
(?:
|
91
|
-
\.
|
92
|
-
(?!gha)
|
93
|
-
[a-zA-Z0-9]+
|
94
|
-
)*
|
95
|
-
)
|
96
|
-
)?
|
97
|
-
|
98
|
-
# build segments: ours include CI info (`gha`), then git (`g`), then branch name
|
99
|
-
(?:
|
100
|
-
\.
|
101
|
-
(?<build>
|
102
|
-
gha(?<gha_run_id>\d+)
|
103
|
-
\.
|
104
|
-
g(?<git_sha>[a-f0-9]+)
|
105
|
-
\.
|
106
|
-
(?<branch>(?:[a-zA-Z0-9.])+)
|
107
|
-
)
|
108
|
-
)?
|
109
|
-
$
|
110
|
-
/xm.freeze
|
79
|
+
semver + pre + build
|
80
|
+
end
|
111
81
|
end
|
112
82
|
end
|
113
83
|
end
|
data/lib/datadog/core/git/ext.rb
CHANGED
@@ -5,32 +5,11 @@ module Datadog
|
|
5
5
|
module Git
|
6
6
|
# Defines constants for Git tags
|
7
7
|
module Ext
|
8
|
-
|
9
|
-
|
10
|
-
TAG_BRANCH = 'git.branch'
|
11
|
-
TAG_REPOSITORY_URL = 'git.repository_url'
|
12
|
-
TAG_TAG = 'git.tag'
|
13
|
-
|
14
|
-
TAG_COMMIT_AUTHOR_DATE = 'git.commit.author.date'
|
15
|
-
TAG_COMMIT_AUTHOR_EMAIL = 'git.commit.author.email'
|
16
|
-
TAG_COMMIT_AUTHOR_NAME = 'git.commit.author.name'
|
17
|
-
TAG_COMMIT_COMMITTER_DATE = 'git.commit.committer.date'
|
18
|
-
TAG_COMMIT_COMMITTER_EMAIL = 'git.commit.committer.email'
|
19
|
-
TAG_COMMIT_COMMITTER_NAME = 'git.commit.committer.name'
|
20
|
-
TAG_COMMIT_MESSAGE = 'git.commit.message'
|
21
|
-
TAG_COMMIT_SHA = 'git.commit.sha'
|
8
|
+
TAG_REPOSITORY_URL = '_dd.git.repository_url'
|
9
|
+
TAG_COMMIT_SHA = '_dd.git.commit.sha'
|
22
10
|
|
23
11
|
ENV_REPOSITORY_URL = 'DD_GIT_REPOSITORY_URL'
|
24
12
|
ENV_COMMIT_SHA = 'DD_GIT_COMMIT_SHA'
|
25
|
-
ENV_BRANCH = 'DD_GIT_BRANCH'
|
26
|
-
ENV_TAG = 'DD_GIT_TAG'
|
27
|
-
ENV_COMMIT_MESSAGE = 'DD_GIT_COMMIT_MESSAGE'
|
28
|
-
ENV_COMMIT_AUTHOR_NAME = 'DD_GIT_COMMIT_AUTHOR_NAME'
|
29
|
-
ENV_COMMIT_AUTHOR_EMAIL = 'DD_GIT_COMMIT_AUTHOR_EMAIL'
|
30
|
-
ENV_COMMIT_AUTHOR_DATE = 'DD_GIT_COMMIT_AUTHOR_DATE'
|
31
|
-
ENV_COMMIT_COMMITTER_NAME = 'DD_GIT_COMMIT_COMMITTER_NAME'
|
32
|
-
ENV_COMMIT_COMMITTER_EMAIL = 'DD_GIT_COMMIT_COMMITTER_EMAIL'
|
33
|
-
ENV_COMMIT_COMMITTER_DATE = 'DD_GIT_COMMIT_COMMITTER_DATE'
|
34
13
|
end
|
35
14
|
end
|
36
15
|
end
|
@@ -13,9 +13,7 @@ module Datadog
|
|
13
13
|
# Configures the HTTP transport to communicate with the agent
|
14
14
|
# to fetch and sync the remote configuration
|
15
15
|
class Component
|
16
|
-
|
17
|
-
|
18
|
-
attr_reader :client
|
16
|
+
attr_reader :client, :healthy
|
19
17
|
|
20
18
|
def initialize(settings, capabilities, agent_settings)
|
21
19
|
transport_options = {}
|
@@ -24,14 +22,14 @@ module Datadog
|
|
24
22
|
negotiation = Negotiation.new(settings, agent_settings)
|
25
23
|
transport_v7 = Datadog::Core::Remote::Transport::HTTP.v7(**transport_options.dup)
|
26
24
|
|
27
|
-
@barrier = Barrier.new(
|
25
|
+
@barrier = Barrier.new(settings.remote.boot_timeout_seconds)
|
28
26
|
|
29
27
|
@client = Client.new(transport_v7, capabilities)
|
30
|
-
healthy = false
|
28
|
+
@healthy = false
|
31
29
|
Datadog.logger.debug { "new remote configuration client: #{@client.id}" }
|
32
30
|
|
33
31
|
@worker = Worker.new(interval: settings.remote.poll_interval_seconds) do
|
34
|
-
unless healthy || negotiation.endpoint?('/v0.7/config')
|
32
|
+
unless @healthy || negotiation.endpoint?('/v0.7/config')
|
35
33
|
@barrier.lift
|
36
34
|
|
37
35
|
next
|
@@ -39,7 +37,7 @@ module Datadog
|
|
39
37
|
|
40
38
|
begin
|
41
39
|
@client.sync
|
42
|
-
healthy ||= true
|
40
|
+
@healthy ||= true
|
43
41
|
rescue Client::SyncError => e
|
44
42
|
Datadog.logger.error do
|
45
43
|
"remote worker client sync error: #{e.message} location: #{Array(e.backtrace).first}. skipping sync"
|
@@ -57,7 +55,7 @@ module Datadog
|
|
57
55
|
|
58
56
|
# client state is unknown, state might be corrupted
|
59
57
|
@client = Client.new(transport_v7, capabilities)
|
60
|
-
healthy = false
|
58
|
+
@healthy = false
|
61
59
|
Datadog.logger.debug { "new remote configuration client: #{@client.id}" }
|
62
60
|
|
63
61
|
# TODO: bail out if too many errors?
|
@@ -103,17 +101,32 @@ module Datadog
|
|
103
101
|
def wait_once(timeout = nil)
|
104
102
|
# TTAS (Test and Test-And-Set) optimisation
|
105
103
|
# Since @once only ever goes from false to true, this is semantically valid
|
106
|
-
return if @once
|
104
|
+
return :pass if @once
|
107
105
|
|
108
106
|
begin
|
109
107
|
@mutex.lock
|
110
108
|
|
111
|
-
return if @once
|
109
|
+
return :pass if @once
|
112
110
|
|
113
111
|
timeout ||= @timeout
|
114
112
|
|
115
|
-
#
|
116
|
-
|
113
|
+
# - starting with Ruby 3.2, ConditionVariable#wait returns nil on
|
114
|
+
# timeout and an integer otherwise
|
115
|
+
# - before Ruby 3.2, ConditionVariable returns itself
|
116
|
+
# so we have to rely on @once having been set
|
117
|
+
if RUBY_VERSION >= '3.2'
|
118
|
+
lifted = @condition.wait(@mutex, timeout)
|
119
|
+
else
|
120
|
+
@condition.wait(@mutex, timeout)
|
121
|
+
lifted = @once
|
122
|
+
end
|
123
|
+
|
124
|
+
if lifted
|
125
|
+
:lift
|
126
|
+
else
|
127
|
+
@once = true
|
128
|
+
:timeout
|
129
|
+
end
|
117
130
|
ensure
|
118
131
|
@mutex.unlock
|
119
132
|
end
|
@@ -7,12 +7,12 @@ module Datadog
|
|
7
7
|
module Remote
|
8
8
|
# Endpoint negotiation
|
9
9
|
class Negotiation
|
10
|
-
def initialize(_settings, agent_settings)
|
10
|
+
def initialize(_settings, agent_settings, suppress_logging: {})
|
11
11
|
transport_options = {}
|
12
12
|
transport_options[:agent_settings] = agent_settings if agent_settings
|
13
13
|
|
14
14
|
@transport_root = Datadog::Core::Remote::Transport::HTTP.root(**transport_options.dup)
|
15
|
-
@logged =
|
15
|
+
@logged = suppress_logging
|
16
16
|
end
|
17
17
|
|
18
18
|
def endpoint?(path)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../tie'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Core
|
7
|
+
module Remote
|
8
|
+
module Tie
|
9
|
+
# Extend Remote Configuration abilities with Tracing
|
10
|
+
module Tracing
|
11
|
+
# Tag per-request Remote Configuration metadata using Tracing
|
12
|
+
def self.tag(boot, span)
|
13
|
+
return if boot.nil?
|
14
|
+
return if span.nil?
|
15
|
+
|
16
|
+
return if Datadog::Core::Remote.active_remote.nil?
|
17
|
+
|
18
|
+
# TODO: this is not thread-consistent
|
19
|
+
ready = Datadog::Core::Remote.active_remote.healthy
|
20
|
+
status = ready ? 'ready' : 'disconnected'
|
21
|
+
|
22
|
+
span.set_tag('_dd.rc.client_id', Datadog::Core::Remote.active_remote.client.id)
|
23
|
+
span.set_tag('_dd.rc.status', status)
|
24
|
+
|
25
|
+
if boot.barrier != :pass
|
26
|
+
span.set_tag('_dd.rc.boot.time', boot.time)
|
27
|
+
|
28
|
+
if boot.barrier == :timeout
|
29
|
+
span.set_tag('_dd.rc.boot.timeout', true)
|
30
|
+
else
|
31
|
+
span.set_tag('_dd.rc.boot.ready', ready)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Core
|
5
|
+
module Remote
|
6
|
+
# Provide Remote Configuration extensions to other components
|
7
|
+
module Tie
|
8
|
+
Boot = Struct.new(
|
9
|
+
:barrier,
|
10
|
+
:time,
|
11
|
+
)
|
12
|
+
|
13
|
+
def self.boot
|
14
|
+
return if Datadog::Core::Remote.active_remote.nil?
|
15
|
+
|
16
|
+
barrier = nil
|
17
|
+
|
18
|
+
t = Datadog::Core::Utils::Time.measure do
|
19
|
+
barrier = Datadog::Core::Remote.active_remote.barrier(:once)
|
20
|
+
end
|
21
|
+
|
22
|
+
Boot.new(barrier, t)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -10,8 +10,8 @@ module Datadog
|
|
10
10
|
@thr = nil
|
11
11
|
|
12
12
|
@starting = false
|
13
|
-
@stopping = false
|
14
13
|
@started = false
|
14
|
+
@stopped = false
|
15
15
|
|
16
16
|
@interval = interval
|
17
17
|
raise ArgumentError, 'can not initialize a worker without a block' unless block
|
@@ -24,6 +24,11 @@ module Datadog
|
|
24
24
|
|
25
25
|
acquire_lock
|
26
26
|
|
27
|
+
if @stopped
|
28
|
+
Datadog.logger.debug('remote worker: refusing to restart after previous stop')
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
27
32
|
return if @starting || @started
|
28
33
|
|
29
34
|
@starting = true
|
@@ -46,8 +51,6 @@ module Datadog
|
|
46
51
|
|
47
52
|
acquire_lock
|
48
53
|
|
49
|
-
@stopping = true
|
50
|
-
|
51
54
|
thread = @thr
|
52
55
|
|
53
56
|
if thread
|
@@ -56,8 +59,8 @@ module Datadog
|
|
56
59
|
end
|
57
60
|
|
58
61
|
@started = false
|
59
|
-
@stopping = false
|
60
62
|
@thr = nil
|
63
|
+
@stopped = true
|
61
64
|
|
62
65
|
Datadog.logger.debug { 'remote worker stopped' }
|
63
66
|
ensure
|
@@ -25,6 +25,8 @@ module Datadog
|
|
25
25
|
HEADER_META_LANG = 'Datadog-Meta-Lang'
|
26
26
|
HEADER_META_LANG_VERSION = 'Datadog-Meta-Lang-Version'
|
27
27
|
HEADER_META_LANG_INTERPRETER = 'Datadog-Meta-Lang-Interpreter'
|
28
|
+
# Use for distinguishing between CRuby, JRuby, and TruffleRuby.
|
29
|
+
HEADER_META_LANG_INTERPRETER_VENDOR = 'Datadog-Meta-Lang-Interpreter-Vendor'
|
28
30
|
HEADER_META_TRACER_VERSION = 'Datadog-Meta-Tracer-Version'
|
29
31
|
|
30
32
|
# Header that prevents the Net::HTTP integration from tracing internal trace requests.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Core
|
7
|
+
module Utils
|
8
|
+
# Helpers class that provides methods to process URLs
|
9
|
+
# such as filtering sensitive information.
|
10
|
+
module Url
|
11
|
+
def self.filter_basic_auth(url)
|
12
|
+
return nil if url.nil?
|
13
|
+
|
14
|
+
URI(url).tap do |u|
|
15
|
+
u.user = nil
|
16
|
+
u.password = nil
|
17
|
+
end.to_s
|
18
|
+
# Git scheme: git@github.com:DataDog/dd-trace-rb.git
|
19
|
+
rescue URI::InvalidURIError
|
20
|
+
url
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|