ddtrace 1.20.0 → 1.22.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 +115 -1
- 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 +238 -61
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_discrete_dynamic_sampler.c +145 -72
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_discrete_dynamic_sampler.h +17 -5
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_thread_context.c +97 -4
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/extconf.rb +2 -2
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/heap_recorder.c +45 -3
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/heap_recorder.h +7 -1
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/http_transport.c +15 -19
- 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 +1 -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}/stack_recorder.c +7 -9
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +43 -13
- data/lib/datadog/appsec/event.rb +1 -1
- data/lib/datadog/auto_instrument.rb +3 -0
- data/lib/datadog/core/configuration/components.rb +7 -6
- data/lib/datadog/core/configuration/option.rb +8 -6
- data/lib/datadog/core/configuration/settings.rb +130 -63
- data/lib/datadog/core/configuration.rb +20 -4
- data/lib/datadog/core/diagnostics/environment_logger.rb +4 -3
- data/lib/datadog/core/environment/git.rb +25 -0
- data/lib/datadog/core/environment/identity.rb +18 -48
- data/lib/datadog/core/environment/platform.rb +7 -1
- data/lib/datadog/core/git/ext.rb +2 -23
- data/lib/datadog/core/remote/client/capabilities.rb +1 -1
- data/lib/datadog/core/remote/negotiation.rb +2 -2
- data/lib/datadog/core/remote/transport/http/config.rb +1 -1
- data/lib/datadog/core/remote/worker.rb +7 -4
- data/lib/datadog/core/telemetry/client.rb +18 -10
- data/lib/datadog/core/telemetry/emitter.rb +9 -13
- data/lib/datadog/core/telemetry/event.rb +247 -57
- data/lib/datadog/core/telemetry/ext.rb +1 -0
- data/lib/datadog/core/telemetry/heartbeat.rb +1 -3
- data/lib/datadog/core/telemetry/http/ext.rb +4 -1
- data/lib/datadog/core/telemetry/http/transport.rb +9 -4
- data/lib/datadog/core/telemetry/request.rb +59 -0
- data/lib/datadog/core/transport/ext.rb +2 -0
- data/lib/datadog/core/utils/url.rb +25 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +10 -4
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +31 -0
- data/lib/datadog/profiling/collectors/info.rb +101 -0
- data/lib/datadog/profiling/component.rb +34 -28
- 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 +19 -6
- 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 +13 -2
- data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +11 -4
- 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/configurable.rb +1 -1
- data/lib/datadog/tracing/contrib/extensions.rb +6 -2
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +11 -4
- data/lib/datadog/tracing/sampling/matcher.rb +23 -3
- data/lib/datadog/tracing/sampling/rule.rb +7 -2
- data/lib/datadog/tracing/sampling/rule_sampler.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/ddtrace/version.rb +1 -1
- metadata +55 -62
- 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/core/telemetry/collector.rb +0 -250
- data/lib/datadog/core/telemetry/v1/app_event.rb +0 -59
- data/lib/datadog/core/telemetry/v1/application.rb +0 -92
- data/lib/datadog/core/telemetry/v1/configuration.rb +0 -25
- data/lib/datadog/core/telemetry/v1/dependency.rb +0 -43
- data/lib/datadog/core/telemetry/v1/host.rb +0 -59
- data/lib/datadog/core/telemetry/v1/install_signature.rb +0 -38
- data/lib/datadog/core/telemetry/v1/integration.rb +0 -64
- data/lib/datadog/core/telemetry/v1/product.rb +0 -36
- data/lib/datadog/core/telemetry/v1/telemetry_request.rb +0 -106
- data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +0 -41
- data/lib/datadog/core/telemetry/v2/request.rb +0 -29
- 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}/helpers.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.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/time_helpers.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/time_helpers.h +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
|
|
@@ -248,18 +266,23 @@ module Datadog
|
|
248
266
|
|
249
267
|
# Can be used to disable the gathering of names and versions of gems in use by the service, used to power
|
250
268
|
# grouping and categorization of stack traces.
|
251
|
-
option :code_provenance_enabled
|
269
|
+
option :code_provenance_enabled do |o|
|
270
|
+
o.type :bool
|
271
|
+
o.default true
|
272
|
+
end
|
252
273
|
|
253
274
|
# @deprecated No longer does anything, and will be removed on dd-trace-rb 2.0.
|
254
275
|
#
|
255
276
|
# This was added as a temporary support option in case of issues with the new `Profiling::HttpTransport` class
|
256
277
|
# but we're now confident it's working nicely so we've removed the old code path.
|
257
278
|
option :legacy_transport_enabled do |o|
|
258
|
-
o.after_set do
|
259
|
-
Datadog
|
260
|
-
|
261
|
-
|
262
|
-
|
279
|
+
o.after_set do |_, _, precedence|
|
280
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
281
|
+
Datadog.logger.warn(
|
282
|
+
'The profiling.advanced.legacy_transport_enabled setting has been deprecated for removal and no ' \
|
283
|
+
'longer does anything. Please remove it from your Datadog.configure block.'
|
284
|
+
)
|
285
|
+
end
|
263
286
|
end
|
264
287
|
end
|
265
288
|
|
@@ -268,11 +291,13 @@ module Datadog
|
|
268
291
|
# This was used prior to the GA of the new CPU Profiling 2.0 profiler. Using CPU Profiling 2.0 is now the
|
269
292
|
# default and this doesn't do anything.
|
270
293
|
option :force_enable_new_profiler do |o|
|
271
|
-
o.after_set do
|
272
|
-
Datadog
|
273
|
-
|
274
|
-
|
275
|
-
|
294
|
+
o.after_set do |_, _, precedence|
|
295
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
296
|
+
Datadog.logger.warn(
|
297
|
+
'The profiling.advanced.force_enable_new_profiler setting has been deprecated for removal and no ' \
|
298
|
+
'longer does anything. Please remove it from your Datadog.configure block.'
|
299
|
+
)
|
300
|
+
end
|
276
301
|
end
|
277
302
|
end
|
278
303
|
|
@@ -281,63 +306,75 @@ module Datadog
|
|
281
306
|
# This was used prior to the GA of the new CPU Profiling 2.0 profiler. Using CPU Profiling 2.0 is now the
|
282
307
|
# default and this doesn't do anything.
|
283
308
|
option :force_enable_legacy_profiler do |o|
|
284
|
-
o.after_set do
|
285
|
-
Datadog
|
286
|
-
|
287
|
-
|
288
|
-
|
309
|
+
o.after_set do |_, _, precedence|
|
310
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
311
|
+
Datadog.logger.warn(
|
312
|
+
'The profiling.advanced.force_enable_legacy_profiler setting has been deprecated for removal and no ' \
|
313
|
+
'longer does anything. Please remove it from your Datadog.configure block.'
|
314
|
+
)
|
315
|
+
end
|
289
316
|
end
|
290
317
|
end
|
291
318
|
|
292
|
-
#
|
319
|
+
# @deprecated No longer does anything, and will be removed on dd-trace-rb 2.0.
|
293
320
|
#
|
294
|
-
#
|
295
|
-
|
321
|
+
# GC profiling is now on by default and controlled by {:gc_enabled}.
|
322
|
+
option :force_enable_gc_profiling do |o|
|
323
|
+
o.after_set do |_, _, precedence|
|
324
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
325
|
+
Datadog.logger.warn(
|
326
|
+
'The profiling.advanced.force_enable_gc_profiling setting has been deprecated for removal and no ' \
|
327
|
+
'longer does anything (the feature is now on by default). ' \
|
328
|
+
'Please remove this setting from your Datadog.configure block.'
|
329
|
+
)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
# Can be used to enable/disable garbage collection profiling.
|
296
335
|
#
|
297
|
-
#
|
298
|
-
#
|
299
|
-
#
|
300
|
-
# Ractors due to two Ruby VM bugs:
|
301
|
-
# https://bugs.ruby-lang.org/issues/19112 AND https://bugs.ruby-lang.org/issues/18464.
|
302
|
-
# If you use Ruby 3.x and your application does not use Ractors (or if your Ruby has been patched), the
|
303
|
-
# feature is fully safe to enable and this toggle can be used to do so.
|
336
|
+
# @warn To avoid https://bugs.ruby-lang.org/issues/18464 even when enabled, GC profiling is only started
|
337
|
+
# for Ruby versions 2.x, 3.1.4+, 3.2.3+ and 3.3.0+
|
338
|
+
# (more details in {Datadog::Profiling::Component.enable_gc_profiling?})
|
304
339
|
#
|
305
|
-
#
|
306
|
-
#
|
340
|
+
# @warn Due to a VM bug in the Ractor implementation (https://bugs.ruby-lang.org/issues/19112) this feature
|
341
|
+
# stops working when Ractors get garbage collected.
|
307
342
|
#
|
308
|
-
# @default `
|
309
|
-
option :
|
310
|
-
o.env 'DD_PROFILING_FORCE_ENABLE_GC'
|
343
|
+
# @default `DD_PROFILING_GC_ENABLED` environment variable, otherwise `true`
|
344
|
+
option :gc_enabled do |o|
|
311
345
|
o.type :bool
|
312
|
-
o.
|
346
|
+
o.env 'DD_PROFILING_GC_ENABLED'
|
347
|
+
o.default true
|
313
348
|
end
|
314
349
|
|
315
350
|
# Can be used to enable/disable the Datadog::Profiling.allocation_count feature.
|
316
351
|
#
|
317
|
-
#
|
352
|
+
# @deprecated Use {:allocation_enabled} (outside of advanced section) instead.
|
318
353
|
option :allocation_counting_enabled do |o|
|
319
|
-
o.after_set do
|
320
|
-
Datadog
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
354
|
+
o.after_set do |_, _, precedence|
|
355
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
356
|
+
Datadog.logger.warn(
|
357
|
+
'The profiling.advanced.allocation_counting_enabled setting has been deprecated for removal and no ' \
|
358
|
+
'longer does anything. Please remove it from your Datadog.configure block. ' \
|
359
|
+
'Allocation counting is now controlled by the profiling.allocation_enabled setting instead.'
|
360
|
+
)
|
361
|
+
end
|
325
362
|
end
|
326
363
|
end
|
327
364
|
|
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`
|
365
|
+
# @deprecated Use {:allocation_enabled} (outside of advanced section) instead.
|
337
366
|
option :experimental_allocation_enabled do |o|
|
338
367
|
o.type :bool
|
339
|
-
o.env 'DD_PROFILING_EXPERIMENTAL_ALLOCATION_ENABLED'
|
340
368
|
o.default false
|
369
|
+
o.after_set do |_, _, precedence|
|
370
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
371
|
+
Datadog.logger.warn(
|
372
|
+
'The profiling.advanced.experimental_allocation_enabled setting has been deprecated for removal and ' \
|
373
|
+
'no longer does anything. Please remove it from your Datadog.configure block. ' \
|
374
|
+
'Allocation profiling is now controlled by the profiling.allocation_enabled setting instead.'
|
375
|
+
)
|
376
|
+
end
|
377
|
+
end
|
341
378
|
end
|
342
379
|
|
343
380
|
# Can be used to enable/disable the collection of heap profiles.
|
@@ -371,13 +408,15 @@ module Datadog
|
|
371
408
|
#
|
372
409
|
# This feature is now controlled via {:overhead_target_percentage}
|
373
410
|
option :experimental_allocation_sample_rate do |o|
|
374
|
-
o.after_set do
|
375
|
-
Datadog
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
411
|
+
o.after_set do |_, _, precedence|
|
412
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
413
|
+
Datadog.logger.warn(
|
414
|
+
'The profiling.advanced.experimental_allocation_sample_rate setting has been deprecated for removal ' \
|
415
|
+
'and no longer does anything. Please remove it from your Datadog.configure block. ' \
|
416
|
+
'Allocation sample rate is now handled by a dynamic sampler which will adjust the sampling rate to ' \
|
417
|
+
'keep to the configured `profiling.advanced.overhead_target_percentage`.'
|
418
|
+
)
|
419
|
+
end
|
381
420
|
end
|
382
421
|
end
|
383
422
|
|
@@ -412,9 +451,27 @@ module Datadog
|
|
412
451
|
#
|
413
452
|
# @default `DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED` environment variable as a boolean, otherwise `false`
|
414
453
|
option :experimental_timeline_enabled do |o|
|
454
|
+
o.after_set do |_, _, precedence|
|
455
|
+
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
456
|
+
Datadog.logger.warn(
|
457
|
+
'The profiling.advanced.experimental_timeline_enabled setting has been deprecated for removal ' \
|
458
|
+
'and no longer does anything. Please remove it from your Datadog.configure block. ' \
|
459
|
+
'The timeline feature counting is now controlled by the `timeline_enabled` setting instead.'
|
460
|
+
)
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
# Controls data collection for the timeline feature.
|
466
|
+
#
|
467
|
+
# If you needed to disable this, please tell us why on <https://github.com/DataDog/dd-trace-rb/issues/new>,
|
468
|
+
# so we can fix it!
|
469
|
+
#
|
470
|
+
# @default `DD_PROFILING_TIMELINE_ENABLED` environment variable as a boolean, otherwise `true`
|
471
|
+
option :timeline_enabled do |o|
|
415
472
|
o.type :bool
|
416
|
-
o.env '
|
417
|
-
o.default
|
473
|
+
o.env 'DD_PROFILING_TIMELINE_ENABLED'
|
474
|
+
o.default true
|
418
475
|
end
|
419
476
|
|
420
477
|
# The profiler gathers data by sending `SIGPROF` unix signals to Ruby application threads.
|
@@ -641,6 +698,16 @@ module Datadog
|
|
641
698
|
# Client-side telemetry configuration
|
642
699
|
# @public_api
|
643
700
|
settings :telemetry do
|
701
|
+
# Whether the bundled Ruby gems as reported through telemetry.
|
702
|
+
#
|
703
|
+
# @default `DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED` environment variable, otherwise `true`.
|
704
|
+
# @return [Boolean]
|
705
|
+
option :dependency_collection do |o|
|
706
|
+
o.type :bool
|
707
|
+
o.env Core::Telemetry::Ext::ENV_DEPENDENCY_COLLECTION
|
708
|
+
o.default true
|
709
|
+
end
|
710
|
+
|
644
711
|
# Enable telemetry collection. This allows telemetry events to be emitted to the telemetry API.
|
645
712
|
#
|
646
713
|
# @default `DD_INSTRUMENTATION_TELEMETRY_ENABLED` environment variable, otherwise `true`.
|
@@ -81,18 +81,23 @@ module Datadog
|
|
81
81
|
configuration = self.configuration
|
82
82
|
yield(configuration)
|
83
83
|
|
84
|
-
|
84
|
+
built_components = false
|
85
|
+
|
86
|
+
components = safely_synchronize do |write_components|
|
85
87
|
write_components.call(
|
86
88
|
if components?
|
87
89
|
replace_components!(configuration, @components)
|
88
90
|
else
|
89
91
|
components = build_components(configuration)
|
90
|
-
|
92
|
+
built_components = true
|
91
93
|
components
|
92
94
|
end
|
93
95
|
)
|
94
96
|
end
|
95
97
|
|
98
|
+
# Should only be called the first time components are built
|
99
|
+
components.telemetry.started! if built_components
|
100
|
+
|
96
101
|
configuration
|
97
102
|
end
|
98
103
|
|
@@ -192,9 +197,20 @@ module Datadog
|
|
192
197
|
current_components = COMPONENTS_READ_LOCK.synchronize { defined?(@components) && @components }
|
193
198
|
return current_components if current_components || !allow_initialization
|
194
199
|
|
195
|
-
|
196
|
-
|
200
|
+
built_components = false
|
201
|
+
|
202
|
+
components = safely_synchronize do |write_components|
|
203
|
+
if defined?(@components) && @components
|
204
|
+
@components
|
205
|
+
else
|
206
|
+
built_components = true
|
207
|
+
write_components.call(build_components(configuration))
|
208
|
+
end
|
197
209
|
end
|
210
|
+
|
211
|
+
# Should only be called the first time components are built
|
212
|
+
components.telemetry.started! if built_components && components && components.telemetry
|
213
|
+
components
|
198
214
|
end
|
199
215
|
|
200
216
|
private
|
@@ -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.
|
@@ -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
|
@@ -9,12 +9,18 @@ module Datadog
|
|
9
9
|
module Platform
|
10
10
|
module_function
|
11
11
|
|
12
|
+
# @return [String] ISA of host; `uname -m`
|
13
|
+
def architecture
|
14
|
+
Identity.lang_version >= '2.2' ? Etc.uname[:machine] : Gem::Platform.local.cpu
|
15
|
+
end
|
16
|
+
|
12
17
|
# @return [String] name of host; `uname -n`
|
13
18
|
def hostname
|
14
19
|
Identity.lang_version >= '2.2' ? Etc.uname[:nodename] : nil
|
15
20
|
end
|
16
21
|
|
17
|
-
#
|
22
|
+
# System name, normally `Linux` or `Darwin` (but 'Mac OS X' on JRuby);
|
23
|
+
# @return [String] name of kernel; `uname -s`.
|
18
24
|
def kernel_name
|
19
25
|
Identity.lang_version >= '2.2' ? Etc.uname[:sysname] : Gem::Platform.local.os.capitalize
|
20
26
|
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
|
@@ -53,7 +53,7 @@ module Datadog
|
|
53
53
|
cap_to_hexs = capabilities.reduce(:|).to_s(16).tap { |s| s.size.odd? && s.prepend('0') }.scan(/\h\h/)
|
54
54
|
binary = cap_to_hexs.each_with_object([]) { |hex, acc| acc << hex }.map { |e| e.to_i(16) }.pack('C*')
|
55
55
|
|
56
|
-
Base64.
|
56
|
+
Base64.strict_encode64(binary)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
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)
|
@@ -51,7 +51,7 @@ module Datadog
|
|
51
51
|
|
52
52
|
# TODO: these fallbacks should be improved
|
53
53
|
roots = payload[:roots] || []
|
54
|
-
targets = payload[:targets] || Base64.
|
54
|
+
targets = payload[:targets] || Base64.strict_encode64('{}')
|
55
55
|
target_files = payload[:target_files] || []
|
56
56
|
client_configs = payload[:client_configs] || []
|
57
57
|
|
@@ -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
|