ddtrace 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +61 -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 +206 -49
- 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 +92 -2
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/extconf.rb +2 -2
- 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 +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/lib/datadog/core/configuration/components.rb +5 -5
- data/lib/datadog/core/configuration/option.rb +1 -1
- data/lib/datadog/core/configuration/settings.rb +92 -46
- 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/git/ext.rb +2 -23
- data/lib/datadog/core/remote/negotiation.rb +2 -2
- 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/profiling/collectors/cpu_and_wall_time_worker.rb +6 -0
- data/lib/datadog/profiling/collectors/info.rb +101 -0
- data/lib/datadog/profiling/component.rb +12 -14
- 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/contrib/concurrent_ruby/async_patch.rb +20 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +11 -1
- data/lib/datadog/tracing/contrib/extensions.rb +6 -2
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +5 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +11 -4
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +28 -4
- data/lib/datadog/tracing/contrib/rails/patcher.rb +16 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer.rb +6 -3
- 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/ddtrace/version.rb +1 -1
- metadata +56 -53
- 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}/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.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
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/time_helpers.h +0 -0
data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/http_transport.c
RENAMED
|
@@ -46,17 +46,17 @@ static VALUE _native_do_export(
|
|
|
46
46
|
VALUE code_provenance_file_name,
|
|
47
47
|
VALUE code_provenance_data,
|
|
48
48
|
VALUE tags_as_array,
|
|
49
|
-
VALUE internal_metadata_json
|
|
49
|
+
VALUE internal_metadata_json,
|
|
50
|
+
VALUE info_json
|
|
50
51
|
);
|
|
51
52
|
static void *call_exporter_without_gvl(void *call_args);
|
|
52
53
|
static void interrupt_exporter_call(void *cancel_token);
|
|
53
|
-
static VALUE ddtrace_version(void);
|
|
54
54
|
|
|
55
55
|
void http_transport_init(VALUE profiling_module) {
|
|
56
56
|
VALUE http_transport_class = rb_define_class_under(profiling_module, "HttpTransport", rb_cObject);
|
|
57
57
|
|
|
58
58
|
rb_define_singleton_method(http_transport_class, "_native_validate_exporter", _native_validate_exporter, 1);
|
|
59
|
-
rb_define_singleton_method(http_transport_class, "_native_do_export", _native_do_export,
|
|
59
|
+
rb_define_singleton_method(http_transport_class, "_native_do_export", _native_do_export, 13);
|
|
60
60
|
|
|
61
61
|
ok_symbol = ID2SYM(rb_intern_const("ok"));
|
|
62
62
|
error_symbol = ID2SYM(rb_intern_const("error"));
|
|
@@ -208,6 +208,7 @@ static VALUE perform_export(
|
|
|
208
208
|
ddog_prof_Exporter_Slice_File files_to_export_unmodified,
|
|
209
209
|
ddog_Vec_Tag *additional_tags,
|
|
210
210
|
ddog_CharSlice internal_metadata,
|
|
211
|
+
ddog_CharSlice info,
|
|
211
212
|
uint64_t timeout_milliseconds
|
|
212
213
|
) {
|
|
213
214
|
ddog_prof_ProfiledEndpointsStats *endpoints_stats = NULL; // Not in use yet
|
|
@@ -220,6 +221,7 @@ static VALUE perform_export(
|
|
|
220
221
|
additional_tags,
|
|
221
222
|
endpoints_stats,
|
|
222
223
|
&internal_metadata,
|
|
224
|
+
&info,
|
|
223
225
|
timeout_milliseconds
|
|
224
226
|
);
|
|
225
227
|
|
|
@@ -290,7 +292,8 @@ static VALUE _native_do_export(
|
|
|
290
292
|
VALUE code_provenance_file_name,
|
|
291
293
|
VALUE code_provenance_data,
|
|
292
294
|
VALUE tags_as_array,
|
|
293
|
-
VALUE internal_metadata_json
|
|
295
|
+
VALUE internal_metadata_json,
|
|
296
|
+
VALUE info_json
|
|
294
297
|
) {
|
|
295
298
|
ENFORCE_TYPE(upload_timeout_milliseconds, T_FIXNUM);
|
|
296
299
|
ENFORCE_TYPE(start_timespec_seconds, T_FIXNUM);
|
|
@@ -301,6 +304,7 @@ static VALUE _native_do_export(
|
|
|
301
304
|
ENFORCE_TYPE(pprof_data, T_STRING);
|
|
302
305
|
ENFORCE_TYPE(code_provenance_file_name, T_STRING);
|
|
303
306
|
ENFORCE_TYPE(internal_metadata_json, T_STRING);
|
|
307
|
+
ENFORCE_TYPE(info_json, T_STRING);
|
|
304
308
|
|
|
305
309
|
// Code provenance can be disabled and in that case will be set to nil
|
|
306
310
|
bool have_code_provenance = !NIL_P(code_provenance_data);
|
|
@@ -335,6 +339,7 @@ static VALUE _native_do_export(
|
|
|
335
339
|
|
|
336
340
|
ddog_Vec_Tag *null_additional_tags = NULL;
|
|
337
341
|
ddog_CharSlice internal_metadata = char_slice_from_ruby_string(internal_metadata_json);
|
|
342
|
+
ddog_CharSlice info = char_slice_from_ruby_string(info_json);
|
|
338
343
|
|
|
339
344
|
ddog_prof_Exporter_NewResult exporter_result = create_exporter(exporter_configuration, tags_as_array);
|
|
340
345
|
// Note: Do not add anything that can raise exceptions after this line, as otherwise the exporter memory will leak
|
|
@@ -350,6 +355,7 @@ static VALUE _native_do_export(
|
|
|
350
355
|
files_to_export_unmodified,
|
|
351
356
|
null_additional_tags,
|
|
352
357
|
internal_metadata,
|
|
358
|
+
info,
|
|
353
359
|
timeout_milliseconds
|
|
354
360
|
);
|
|
355
361
|
}
|
|
@@ -367,13 +373,3 @@ static void *call_exporter_without_gvl(void *call_args) {
|
|
|
367
373
|
static void interrupt_exporter_call(void *cancel_token) {
|
|
368
374
|
ddog_CancellationToken_cancel((ddog_CancellationToken *) cancel_token);
|
|
369
375
|
}
|
|
370
|
-
|
|
371
|
-
static VALUE ddtrace_version(void) {
|
|
372
|
-
VALUE ddtrace_module = rb_const_get(rb_cObject, rb_intern("DDTrace"));
|
|
373
|
-
ENFORCE_TYPE(ddtrace_module, T_MODULE);
|
|
374
|
-
VALUE version_module = rb_const_get(ddtrace_module, rb_intern("VERSION"));
|
|
375
|
-
ENFORCE_TYPE(version_module, T_MODULE);
|
|
376
|
-
VALUE version_string = rb_const_get(version_module, rb_intern("STRING"));
|
|
377
|
-
ENFORCE_TYPE(version_string, T_STRING);
|
|
378
|
-
return version_string;
|
|
379
|
-
}
|
|
@@ -15,7 +15,7 @@ module Datadog
|
|
|
15
15
|
# The MJIT header was introduced on 2.6 and removed on 3.3; for other Rubies we rely on debase-ruby_core_source
|
|
16
16
|
CAN_USE_MJIT_HEADER = RUBY_VERSION.start_with?('2.6', '2.7', '3.0.', '3.1.', '3.2.')
|
|
17
17
|
|
|
18
|
-
LIBDATADOG_VERSION = '~>
|
|
18
|
+
LIBDATADOG_VERSION = '~> 6.0.0.2.0'
|
|
19
19
|
|
|
20
20
|
def self.fail_install_if_missing_extension?
|
|
21
21
|
ENV[ENV_FAIL_INSTALL_IF_MISSING_EXTENSION].to_s.strip.downcase == 'true'
|
|
@@ -29,7 +29,7 @@ module Datadog
|
|
|
29
29
|
# native extension), we need to add a "runpath" -- a list of folders to search for libdatadog.
|
|
30
30
|
#
|
|
31
31
|
# This runpath gets hardcoded at native library linking time. You can look at it using the `readelf` tool in
|
|
32
|
-
# Linux: e.g. `readelf -d
|
|
32
|
+
# Linux: e.g. `readelf -d datadog_profiling_native_extension.2.7.3_x86_64-linux.so`.
|
|
33
33
|
#
|
|
34
34
|
# In older versions of ddtrace, we only set as runpath an absolute path to libdatadog.
|
|
35
35
|
# (This gets set automatically by the call
|
|
@@ -305,8 +305,8 @@ module Datadog
|
|
|
305
305
|
no_binaries_for_current_platform = explain_issue(
|
|
306
306
|
'the `libdatadog` gem installed on your system is missing binaries for your',
|
|
307
307
|
'platform variant.',
|
|
308
|
-
"(Your platform: `#{
|
|
309
|
-
'(Available binaries:
|
|
308
|
+
"(Your platform: `#{Libdatadog.current_platform}`)",
|
|
309
|
+
'(Available binaries:',
|
|
310
310
|
"`#{Libdatadog.available_binaries.join('`, `')}`)",
|
|
311
311
|
suggested: CONTACT_SUPPORT,
|
|
312
312
|
)
|
|
@@ -876,3 +876,17 @@ static inline int ddtrace_imemo_type(VALUE imemo) {
|
|
|
876
876
|
return NULL;
|
|
877
877
|
}
|
|
878
878
|
#endif
|
|
879
|
+
|
|
880
|
+
// This is used to workaround a VM bug. See "handle_sampling_signal" in "collectors_cpu_and_wall_time_worker" for details.
|
|
881
|
+
#ifdef NO_POSTPONED_TRIGGER
|
|
882
|
+
void *objspace_ptr_for_gc_finalize_deferred_workaround(void) {
|
|
883
|
+
rb_vm_t *vm =
|
|
884
|
+
#ifndef NO_GET_VM // TODO: Inline GET_VM below once we drop support in dd-trace-rb 2.x for < Ruby 2.5
|
|
885
|
+
GET_VM();
|
|
886
|
+
#else
|
|
887
|
+
thread_struct_from_object(rb_thread_current())->vm;
|
|
888
|
+
#endif
|
|
889
|
+
|
|
890
|
+
return vm->objspace;
|
|
891
|
+
}
|
|
892
|
+
#endif
|
data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/profiling.c
RENAMED
|
@@ -38,7 +38,7 @@ static VALUE _native_enforce_success(DDTRACE_UNUSED VALUE _self, VALUE syserr_er
|
|
|
38
38
|
static void *trigger_enforce_success(void *trigger_args);
|
|
39
39
|
static VALUE _native_malloc_stats(DDTRACE_UNUSED VALUE _self);
|
|
40
40
|
|
|
41
|
-
void DDTRACE_EXPORT
|
|
41
|
+
void DDTRACE_EXPORT Init_datadog_profiling_native_extension(void) {
|
|
42
42
|
VALUE datadog_module = rb_define_module("Datadog");
|
|
43
43
|
VALUE profiling_module = rb_define_module_under(datadog_module, "Profiling");
|
|
44
44
|
VALUE native_extension_module = rb_define_module_under(profiling_module, "NativeExtension");
|
data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/ruby_helpers.c
RENAMED
|
@@ -255,3 +255,13 @@ VALUE ruby_safe_inspect(VALUE obj) {
|
|
|
255
255
|
return rb_str_new_cstr("(Not inspectable)");
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
+
|
|
259
|
+
VALUE ddtrace_version(void) {
|
|
260
|
+
VALUE ddtrace_module = rb_const_get(rb_cObject, rb_intern("DDTrace"));
|
|
261
|
+
ENFORCE_TYPE(ddtrace_module, T_MODULE);
|
|
262
|
+
VALUE version_module = rb_const_get(ddtrace_module, rb_intern("VERSION"));
|
|
263
|
+
ENFORCE_TYPE(version_module, T_MODULE);
|
|
264
|
+
VALUE version_string = rb_const_get(version_module, rb_intern("STRING"));
|
|
265
|
+
ENFORCE_TYPE(version_string, T_STRING);
|
|
266
|
+
return version_string;
|
|
267
|
+
}
|
data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/ruby_helpers.h
RENAMED
|
@@ -115,3 +115,5 @@ size_t ruby_obj_memsize_of(VALUE obj);
|
|
|
115
115
|
// return a string with the result of that call. Elsif the object responds to
|
|
116
116
|
// 'to_s', return a string with the result of that call. Otherwise, return Qnil.
|
|
117
117
|
VALUE ruby_safe_inspect(VALUE obj);
|
|
118
|
+
|
|
119
|
+
VALUE ddtrace_version(void);
|
|
@@ -81,6 +81,7 @@ module Datadog
|
|
|
81
81
|
|
|
82
82
|
def initialize(settings)
|
|
83
83
|
@logger = self.class.build_logger(settings)
|
|
84
|
+
@environment_logger_extra = {}
|
|
84
85
|
|
|
85
86
|
# This agent_settings is intended for use within Core. If you require
|
|
86
87
|
# agent_settings within a product outside of core you should extend
|
|
@@ -90,11 +91,13 @@ module Datadog
|
|
|
90
91
|
@remote = Remote::Component.build(settings, agent_settings)
|
|
91
92
|
@tracer = self.class.build_tracer(settings, logger: @logger)
|
|
92
93
|
|
|
93
|
-
@profiler = Datadog::Profiling::Component.build_profiler_component(
|
|
94
|
+
@profiler, profiler_logger_extra = Datadog::Profiling::Component.build_profiler_component(
|
|
94
95
|
settings: settings,
|
|
95
96
|
agent_settings: agent_settings,
|
|
96
97
|
optional_tracer: @tracer,
|
|
97
98
|
)
|
|
99
|
+
@environment_logger_extra.merge!(profiler_logger_extra) if profiler_logger_extra
|
|
100
|
+
|
|
98
101
|
@runtime_metrics = self.class.build_runtime_metrics_worker(settings)
|
|
99
102
|
@health_metrics = self.class.build_health_metrics(settings)
|
|
100
103
|
@telemetry = self.class.build_telemetry(settings, agent_settings, logger)
|
|
@@ -105,18 +108,15 @@ module Datadog
|
|
|
105
108
|
def startup!(settings)
|
|
106
109
|
if settings.profiling.enabled
|
|
107
110
|
if profiler
|
|
108
|
-
@logger.debug('Profiling started')
|
|
109
111
|
profiler.start
|
|
110
112
|
else
|
|
111
113
|
# Display a warning for users who expected profiling to be enabled
|
|
112
114
|
unsupported_reason = Profiling.unsupported_reason
|
|
113
115
|
logger.warn("Profiling was requested but is not supported, profiling disabled: #{unsupported_reason}")
|
|
114
116
|
end
|
|
115
|
-
else
|
|
116
|
-
@logger.debug('Profiling is disabled')
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
Core::Diagnostics::EnvironmentLogger.collect_and_log!
|
|
119
|
+
Core::Diagnostics::EnvironmentLogger.collect_and_log!(@environment_logger_extra)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
# Shuts down all the components in use.
|
|
@@ -264,7 +264,7 @@ module Datadog
|
|
|
264
264
|
# when restoring a value from `@value_per_precedence`, and we are only running `definition.setter`
|
|
265
265
|
# on the original value, not on a valud that has already been processed by `definition.setter`.
|
|
266
266
|
@value_per_precedence[precedence] = value
|
|
267
|
-
context_exec(v, old_value, &definition.after_set) if definition.after_set
|
|
267
|
+
context_exec(v, old_value, precedence, &definition.after_set) if definition.after_set
|
|
268
268
|
end
|
|
269
269
|
end
|
|
270
270
|
|
|
@@ -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.
|
|
@@ -371,13 +397,15 @@ module Datadog
|
|
|
371
397
|
#
|
|
372
398
|
# This feature is now controlled via {:overhead_target_percentage}
|
|
373
399
|
option :experimental_allocation_sample_rate do |o|
|
|
374
|
-
o.after_set do
|
|
375
|
-
Datadog
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
|
381
409
|
end
|
|
382
410
|
end
|
|
383
411
|
|
|
@@ -412,9 +440,27 @@ module Datadog
|
|
|
412
440
|
#
|
|
413
441
|
# @default `DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED` environment variable as a boolean, otherwise `false`
|
|
414
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|
|
|
415
461
|
o.type :bool
|
|
416
|
-
o.env '
|
|
417
|
-
o.default
|
|
462
|
+
o.env 'DD_PROFILING_TIMELINE_ENABLED'
|
|
463
|
+
o.default true
|
|
418
464
|
end
|
|
419
465
|
|
|
420
466
|
# The profiler gathers data by sending `SIGPROF` unix signals to Ruby application threads.
|
|
@@ -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
|
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
|
|
@@ -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)
|
|
@@ -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
|