ddtrace 1.7.0 → 1.8.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 +50 -1
- data/README.md +2 -2
- data/ext/ddtrace_profiling_loader/extconf.rb +4 -1
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +1 -1
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +3 -2
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +15 -41
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h +1 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +284 -74
- data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.c +142 -0
- data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.h +14 -0
- data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c +241 -0
- data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.h +3 -0
- data/ext/ddtrace_profiling_native_extension/extconf.rb +21 -7
- data/ext/ddtrace_profiling_native_extension/helpers.h +5 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +8 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +108 -24
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +9 -0
- data/ext/ddtrace_profiling_native_extension/profiling.c +205 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +86 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +28 -6
- data/ext/ddtrace_profiling_native_extension/setup_signal_handler.c +23 -4
- data/ext/ddtrace_profiling_native_extension/setup_signal_handler.h +4 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +15 -18
- data/ext/ddtrace_profiling_native_extension/time_helpers.c +17 -0
- data/ext/ddtrace_profiling_native_extension/time_helpers.h +10 -0
- data/lib/datadog/core/configuration/components.rb +27 -6
- data/lib/datadog/core/configuration/ext.rb +18 -0
- data/lib/datadog/core/configuration/settings.rb +14 -341
- data/lib/datadog/core/diagnostics/health.rb +4 -22
- data/lib/datadog/core/environment/variable_helpers.rb +58 -10
- data/lib/datadog/core/utils.rb +0 -21
- data/lib/datadog/core.rb +21 -1
- data/lib/datadog/opentracer/distributed_headers.rb +2 -2
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +16 -5
- data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +14 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +68 -0
- data/lib/datadog/profiling/stack_recorder.rb +14 -0
- data/lib/datadog/profiling.rb +2 -0
- data/lib/datadog/tracing/configuration/ext.rb +33 -3
- data/lib/datadog/tracing/configuration/settings.rb +433 -0
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/aws/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/dalli/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/ethon/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/excon/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/faraday/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +9 -4
- data/lib/datadog/tracing/contrib/grpc/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +9 -4
- data/lib/datadog/tracing/contrib/http/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/httprb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -2
- data/lib/datadog/tracing/contrib/patcher.rb +3 -2
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/pg/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +12 -2
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/presto/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +10 -12
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/redis/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +30 -23
- data/lib/datadog/tracing/contrib/redis/integration.rb +34 -2
- data/lib/datadog/tracing/contrib/redis/patcher.rb +18 -14
- data/lib/datadog/tracing/contrib/redis/quantize.rb +12 -9
- data/lib/datadog/tracing/contrib/redis/tags.rb +4 -6
- data/lib/datadog/tracing/contrib/redis/trace_middleware.rb +72 -0
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +1 -0
- data/lib/datadog/{core → tracing}/diagnostics/ext.rb +1 -6
- data/lib/datadog/tracing/diagnostics/health.rb +40 -0
- data/lib/datadog/tracing/distributed/{b3.rb → b3_multi.rb} +2 -2
- data/lib/datadog/tracing/distributed/helpers.rb +2 -1
- data/lib/datadog/tracing/distributed/none.rb +19 -0
- data/lib/datadog/tracing/distributed/trace_context.rb +369 -0
- data/lib/datadog/tracing/metadata/ext.rb +1 -1
- data/lib/datadog/tracing/sampling/priority_sampler.rb +11 -0
- data/lib/datadog/tracing/sampling/rate_sampler.rb +3 -3
- data/lib/datadog/tracing/span.rb +3 -19
- data/lib/datadog/tracing/span_operation.rb +5 -4
- data/lib/datadog/tracing/trace_digest.rb +75 -2
- data/lib/datadog/tracing/trace_operation.rb +5 -4
- data/lib/datadog/tracing/utils.rb +50 -0
- data/lib/ddtrace/version.rb +1 -1
- metadata +20 -5
|
@@ -9,18 +9,45 @@ module Datadog
|
|
|
9
9
|
module VariableHelpers
|
|
10
10
|
extend self
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
# Reads an environment variable as a Boolean.
|
|
13
|
+
#
|
|
14
|
+
# @param [String] var environment variable
|
|
15
|
+
# @param [Array<String>] var list of environment variables
|
|
16
|
+
# @param [Boolean] default the default value if the keys in `var` are not present in the environment
|
|
17
|
+
# @param [Boolean] deprecation_warning when `var` is a list, record a deprecation log when
|
|
18
|
+
# the first key in `var` is not used.
|
|
19
|
+
# @return [Boolean] if the environment value is the string `true`
|
|
20
|
+
# @return [default] if the environment value is not found
|
|
21
|
+
def env_to_bool(var, default = nil, deprecation_warning: true)
|
|
22
|
+
var = decode_array(var, deprecation_warning)
|
|
14
23
|
var && ENV.key?(var) ? ENV[var].to_s.strip.downcase == 'true' : default
|
|
15
24
|
end
|
|
16
25
|
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
# Reads an environment variable as an Integer.
|
|
27
|
+
#
|
|
28
|
+
# @param [String] var environment variable
|
|
29
|
+
# @param [Array<String>] var list of environment variables
|
|
30
|
+
# @param [Integer] default the default value if the keys in `var` are not present in the environment
|
|
31
|
+
# @param [Boolean] deprecation_warning when `var` is a list, record a deprecation log when
|
|
32
|
+
# the first key in `var` is not used.
|
|
33
|
+
# @return [Integer] if the environment value is a valid Integer
|
|
34
|
+
# @return [default] if the environment value is not found
|
|
35
|
+
def env_to_int(var, default = nil, deprecation_warning: true)
|
|
36
|
+
var = decode_array(var, deprecation_warning)
|
|
19
37
|
var && ENV.key?(var) ? ENV[var].to_i : default
|
|
20
38
|
end
|
|
21
39
|
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
# Reads an environment variable as a Float.
|
|
41
|
+
#
|
|
42
|
+
# @param [String] var environment variable
|
|
43
|
+
# @param [Array<String>] var list of environment variables
|
|
44
|
+
# @param [Float] default the default value if the keys in `var` are not present in the environment
|
|
45
|
+
# @param [Boolean] deprecation_warning when `var` is a list, record a deprecation log when
|
|
46
|
+
# the first key in `var` is not used.
|
|
47
|
+
# @return [Float] if the environment value is a valid Float
|
|
48
|
+
# @return [default] if the environment value is not found
|
|
49
|
+
def env_to_float(var, default = nil, deprecation_warning: true)
|
|
50
|
+
var = decode_array(var, deprecation_warning)
|
|
24
51
|
var && ENV.key?(var) ? ENV[var].to_f : default
|
|
25
52
|
end
|
|
26
53
|
|
|
@@ -33,8 +60,16 @@ module Datadog
|
|
|
33
60
|
# either trailing or leading are trimmed.
|
|
34
61
|
#
|
|
35
62
|
# Empty entries, after trimmed, are also removed from the result.
|
|
36
|
-
|
|
37
|
-
|
|
63
|
+
#
|
|
64
|
+
# @param [String] var environment variable
|
|
65
|
+
# @param [Array<String>] var list of environment variables
|
|
66
|
+
# @param [Array<Object>] default the default value if the keys in `var` are not present in the environment
|
|
67
|
+
# @param [Boolean] deprecation_warning when `var` is a list, record a deprecation log when
|
|
68
|
+
# the first key in `var` is not used.
|
|
69
|
+
# @return [Array<Object>] if the environment value is a valid list
|
|
70
|
+
# @return [default] if the environment value is not found
|
|
71
|
+
def env_to_list(var, default = [], comma_separated_only:, deprecation_warning: true)
|
|
72
|
+
var = decode_array(var, deprecation_warning)
|
|
38
73
|
if var && ENV.key?(var)
|
|
39
74
|
value = ENV[var]
|
|
40
75
|
|
|
@@ -59,8 +94,21 @@ module Datadog
|
|
|
59
94
|
|
|
60
95
|
private
|
|
61
96
|
|
|
62
|
-
def decode_array(var)
|
|
63
|
-
var.is_a?(Array)
|
|
97
|
+
def decode_array(var, deprecation_warning)
|
|
98
|
+
if var.is_a?(Array)
|
|
99
|
+
var.find.with_index do |env_var, i|
|
|
100
|
+
found = ENV.key?(env_var)
|
|
101
|
+
|
|
102
|
+
# Check if we are using a non-preferred environment variable
|
|
103
|
+
if deprecation_warning && found && i != 0
|
|
104
|
+
Datadog::Core.log_deprecation { "#{env_var} environment variable is deprecated, use #{var.first} instead." }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
found
|
|
108
|
+
end
|
|
109
|
+
else
|
|
110
|
+
var
|
|
111
|
+
end
|
|
64
112
|
end
|
|
65
113
|
end
|
|
66
114
|
end
|
data/lib/datadog/core/utils.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# typed: true
|
|
2
2
|
|
|
3
3
|
require_relative 'utils/forking'
|
|
4
|
-
require_relative '../tracing/span'
|
|
5
4
|
|
|
6
5
|
module Datadog
|
|
7
6
|
module Core
|
|
@@ -11,26 +10,6 @@ module Datadog
|
|
|
11
10
|
extend Forking
|
|
12
11
|
|
|
13
12
|
EMPTY_STRING = ''.encode(::Encoding::UTF_8).freeze
|
|
14
|
-
# We use a custom random number generator because we want no interference
|
|
15
|
-
# with the default one. Using the default prng, we could break code that
|
|
16
|
-
# would rely on srand/rand sequences.
|
|
17
|
-
|
|
18
|
-
# Return a randomly generated integer, valid as a Span ID or Trace ID.
|
|
19
|
-
# This method is thread-safe and fork-safe.
|
|
20
|
-
def self.next_id
|
|
21
|
-
after_fork! { reset! }
|
|
22
|
-
id_rng.rand(Tracing::Span::RUBY_ID_RANGE)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.id_rng
|
|
26
|
-
@id_rng ||= Random.new
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.reset!
|
|
30
|
-
@id_rng = Random.new
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private_class_method :id_rng, :reset!
|
|
34
13
|
|
|
35
14
|
# Stringifies `value` and ensures the outcome is
|
|
36
15
|
# string is no longer than `size`.
|
data/lib/datadog/core.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
require_relative 'core/extensions'
|
|
4
5
|
|
|
@@ -9,6 +10,25 @@ module Datadog
|
|
|
9
10
|
# products. It is a dependency of each product. Contrast with Datadog::Kit
|
|
10
11
|
# for higher-level features.
|
|
11
12
|
module Core
|
|
13
|
+
class << self
|
|
14
|
+
# Records the occurrence of a deprecated operation in this library.
|
|
15
|
+
#
|
|
16
|
+
# Currently, these operations are logged to `Datadog.logger` at `warn` level.
|
|
17
|
+
#
|
|
18
|
+
# `disallowed_next_major` adds a message informing that the deprecated operation
|
|
19
|
+
# won't be allowed in the next major release.
|
|
20
|
+
#
|
|
21
|
+
# @yieldreturn [String] a String with the lazily evaluated deprecation message.
|
|
22
|
+
# @param [Boolean] disallowed_next_major whether this deprecation will be enforced in the next major release.
|
|
23
|
+
def log_deprecation(disallowed_next_major: true)
|
|
24
|
+
Datadog.logger.warn do
|
|
25
|
+
message = yield
|
|
26
|
+
message += ' This will be enforced in the next major release.' if disallowed_next_major
|
|
27
|
+
message
|
|
28
|
+
end
|
|
29
|
+
nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
12
32
|
end
|
|
13
33
|
|
|
14
34
|
extend Core::Extensions
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# typed: true
|
|
2
2
|
|
|
3
|
-
require_relative '../tracing/span'
|
|
4
3
|
require_relative '../tracing/distributed/datadog'
|
|
4
|
+
require_relative '../tracing/utils'
|
|
5
5
|
|
|
6
6
|
module Datadog
|
|
7
7
|
module OpenTracer
|
|
@@ -47,7 +47,7 @@ module Datadog
|
|
|
47
47
|
|
|
48
48
|
def id(header)
|
|
49
49
|
value = @carrier[header].to_i
|
|
50
|
-
return if value.zero? || value >= Datadog::Tracing::
|
|
50
|
+
return if value.zero? || value >= Datadog::Tracing::Utils::EXTERNAL_MAX_ID
|
|
51
51
|
|
|
52
52
|
value < 0 ? value + 0x1_0000_0000_0000_0000 : value
|
|
53
53
|
end
|
|
@@ -20,12 +20,14 @@ module Datadog
|
|
|
20
20
|
max_frames:,
|
|
21
21
|
tracer:,
|
|
22
22
|
gc_profiling_enabled:,
|
|
23
|
-
cpu_and_wall_time_collector: CpuAndWallTime.new(recorder: recorder, max_frames: max_frames, tracer: tracer)
|
|
23
|
+
cpu_and_wall_time_collector: CpuAndWallTime.new(recorder: recorder, max_frames: max_frames, tracer: tracer),
|
|
24
|
+
idle_sampling_helper: IdleSamplingHelper.new
|
|
24
25
|
)
|
|
25
|
-
self.class._native_initialize(self, cpu_and_wall_time_collector, gc_profiling_enabled)
|
|
26
|
+
self.class._native_initialize(self, cpu_and_wall_time_collector, gc_profiling_enabled, idle_sampling_helper)
|
|
26
27
|
@worker_thread = nil
|
|
27
28
|
@failure_exception = nil
|
|
28
29
|
@start_stop_mutex = Mutex.new
|
|
30
|
+
@idle_sampling_helper = idle_sampling_helper
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def start
|
|
@@ -33,6 +35,9 @@ module Datadog
|
|
|
33
35
|
return if @worker_thread && @worker_thread.alive?
|
|
34
36
|
|
|
35
37
|
Datadog.logger.debug { "Starting thread for: #{self}" }
|
|
38
|
+
|
|
39
|
+
@idle_sampling_helper.start
|
|
40
|
+
|
|
36
41
|
@worker_thread = Thread.new do
|
|
37
42
|
begin
|
|
38
43
|
Thread.current.name = self.class.name unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
|
|
@@ -43,7 +48,8 @@ module Datadog
|
|
|
43
48
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
44
49
|
@failure_exception = e
|
|
45
50
|
Datadog.logger.warn(
|
|
46
|
-
|
|
51
|
+
'CpuAndWallTimeWorker thread error. ' \
|
|
52
|
+
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
47
53
|
)
|
|
48
54
|
end
|
|
49
55
|
end
|
|
@@ -60,10 +66,11 @@ module Datadog
|
|
|
60
66
|
@start_stop_mutex.synchronize do
|
|
61
67
|
Datadog.logger.debug('Requesting CpuAndWallTimeWorker thread shut down')
|
|
62
68
|
|
|
69
|
+
@idle_sampling_helper.stop
|
|
70
|
+
|
|
63
71
|
return unless @worker_thread
|
|
64
72
|
|
|
65
|
-
@worker_thread
|
|
66
|
-
self.class._native_stop(self)
|
|
73
|
+
self.class._native_stop(self, @worker_thread)
|
|
67
74
|
|
|
68
75
|
@worker_thread.join
|
|
69
76
|
@worker_thread = nil
|
|
@@ -74,6 +81,10 @@ module Datadog
|
|
|
74
81
|
def reset_after_fork
|
|
75
82
|
self.class._native_reset_after_fork(self)
|
|
76
83
|
end
|
|
84
|
+
|
|
85
|
+
def stats
|
|
86
|
+
self.class._native_stats(self)
|
|
87
|
+
end
|
|
77
88
|
end
|
|
78
89
|
end
|
|
79
90
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# typed: false
|
|
2
|
+
|
|
3
|
+
module Datadog
|
|
4
|
+
module Profiling
|
|
5
|
+
module Collectors
|
|
6
|
+
# Used to pace the rate of profiling samples based on the last observed time for a sample.
|
|
7
|
+
# All of this module is implemented as native code.
|
|
8
|
+
#
|
|
9
|
+
# Methods prefixed with _native_ are implemented in `collectors_dynamic_sampling_rate.c`
|
|
10
|
+
module DynamicSamplingRate
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# typed: false
|
|
2
|
+
|
|
3
|
+
module Datadog
|
|
4
|
+
module Profiling
|
|
5
|
+
module Collectors
|
|
6
|
+
# Used by the Collectors::CpuAndWallTimeWorker to gather samples when the Ruby process is idle.
|
|
7
|
+
# Almost all of this class is implemented as native code.
|
|
8
|
+
#
|
|
9
|
+
# Methods prefixed with _native_ are implemented in `collectors_idle_sampling_helper.c`
|
|
10
|
+
class IdleSamplingHelper
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
attr_accessor :failure_exception
|
|
14
|
+
|
|
15
|
+
public
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@worker_thread = nil
|
|
19
|
+
@start_stop_mutex = Mutex.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def start
|
|
23
|
+
@start_stop_mutex.synchronize do
|
|
24
|
+
return if @worker_thread && @worker_thread.alive?
|
|
25
|
+
|
|
26
|
+
Datadog.logger.debug { "Starting thread for: #{self}" }
|
|
27
|
+
|
|
28
|
+
# The same instance of the IdleSamplingHelper can be reused multiple times, and this resets it back to
|
|
29
|
+
# a pristine state before recreating the worker thread
|
|
30
|
+
self.class._native_reset(self)
|
|
31
|
+
|
|
32
|
+
@worker_thread = Thread.new do
|
|
33
|
+
begin
|
|
34
|
+
Thread.current.name = self.class.name unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
|
|
35
|
+
|
|
36
|
+
self.class._native_idle_sampling_loop(self)
|
|
37
|
+
|
|
38
|
+
Datadog.logger.debug('IdleSamplingHelper thread stopping cleanly')
|
|
39
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
40
|
+
@failure_exception = e
|
|
41
|
+
Datadog.logger.warn(
|
|
42
|
+
'IdleSamplingHelper thread error. ' \
|
|
43
|
+
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
true
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def stop(*_)
|
|
53
|
+
@start_stop_mutex.synchronize do
|
|
54
|
+
Datadog.logger.debug('Requesting IdleSamplingHelper thread shut down')
|
|
55
|
+
|
|
56
|
+
return unless @worker_thread
|
|
57
|
+
|
|
58
|
+
self.class._native_stop(self)
|
|
59
|
+
|
|
60
|
+
@worker_thread.join
|
|
61
|
+
@worker_thread = nil
|
|
62
|
+
@failure_exception = nil
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -34,6 +34,20 @@ module Datadog
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def serialize!
|
|
38
|
+
status, result = @no_concurrent_synchronize_mutex.synchronize { self.class._native_serialize(self) }
|
|
39
|
+
|
|
40
|
+
if status == :ok
|
|
41
|
+
_start, _finish, encoded_pprof = result
|
|
42
|
+
|
|
43
|
+
encoded_pprof
|
|
44
|
+
else
|
|
45
|
+
error_message = result
|
|
46
|
+
|
|
47
|
+
raise("Failed to serialize profiling data: #{error_message}")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
37
51
|
def clear
|
|
38
52
|
status, result = @no_concurrent_synchronize_mutex.synchronize { self.class._native_clear(self) }
|
|
39
53
|
|
data/lib/datadog/profiling.rb
CHANGED
|
@@ -149,6 +149,8 @@ module Datadog
|
|
|
149
149
|
require_relative 'profiling/collectors/code_provenance'
|
|
150
150
|
require_relative 'profiling/collectors/cpu_and_wall_time'
|
|
151
151
|
require_relative 'profiling/collectors/cpu_and_wall_time_worker'
|
|
152
|
+
require_relative 'profiling/collectors/dynamic_sampling_rate'
|
|
153
|
+
require_relative 'profiling/collectors/idle_sampling_helper'
|
|
152
154
|
require_relative 'profiling/collectors/old_stack'
|
|
153
155
|
require_relative 'profiling/collectors/stack'
|
|
154
156
|
require_relative 'profiling/stack_recorder'
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
module Datadog
|
|
4
4
|
module Tracing
|
|
5
5
|
module Configuration
|
|
6
|
+
# Constants for configuration settings
|
|
7
|
+
# e.g. Env vars, default values, enums, etc...
|
|
6
8
|
module Ext
|
|
9
|
+
ENV_ENABLED = 'DD_TRACE_ENABLED'.freeze
|
|
10
|
+
|
|
7
11
|
# @public_api
|
|
8
12
|
module Analytics
|
|
9
13
|
ENV_TRACE_ANALYTICS_ENABLED = 'DD_TRACE_ANALYTICS_ENABLED'.freeze
|
|
@@ -16,11 +20,37 @@ module Datadog
|
|
|
16
20
|
|
|
17
21
|
# @public_api
|
|
18
22
|
module Distributed
|
|
23
|
+
# Custom Datadog format
|
|
19
24
|
PROPAGATION_STYLE_DATADOG = 'Datadog'.freeze
|
|
25
|
+
|
|
26
|
+
PROPAGATION_STYLE_B3_MULTI_HEADER = 'b3multi'.freeze
|
|
27
|
+
# @deprecated Use `b3multi` instead.
|
|
20
28
|
PROPAGATION_STYLE_B3 = 'B3'.freeze
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
|
|
30
|
+
PROPAGATION_STYLE_B3_SINGLE_HEADER = 'b3'.freeze
|
|
31
|
+
# @deprecated Use `b3` instead.
|
|
32
|
+
PROPAGATION_STYLE_B3_SINGLE_HEADER_OLD = 'B3 single header'.freeze
|
|
33
|
+
|
|
34
|
+
# W3C Trace Context
|
|
35
|
+
PROPAGATION_STYLE_TRACE_CONTEXT = 'tracecontext'.freeze
|
|
36
|
+
|
|
37
|
+
# Sets both extract and inject propagation style tho the provided value.
|
|
38
|
+
# Has lower precedence than `DD_TRACE_PROPAGATION_STYLE_INJECT` or
|
|
39
|
+
# `DD_TRACE_PROPAGATION_STYLE_EXTRACT`.
|
|
40
|
+
ENV_PROPAGATION_STYLE = 'DD_TRACE_PROPAGATION_STYLE'.freeze
|
|
41
|
+
|
|
42
|
+
ENV_PROPAGATION_STYLE_INJECT = 'DD_TRACE_PROPAGATION_STYLE_INJECT'.freeze
|
|
43
|
+
# @deprecated Use `DD_TRACE_PROPAGATION_STYLE_INJECT` instead.
|
|
44
|
+
ENV_PROPAGATION_STYLE_INJECT_OLD = 'DD_PROPAGATION_STYLE_INJECT'.freeze
|
|
45
|
+
|
|
46
|
+
ENV_PROPAGATION_STYLE_EXTRACT = 'DD_TRACE_PROPAGATION_STYLE_EXTRACT'.freeze
|
|
47
|
+
# @deprecated Use `DD_TRACE_PROPAGATION_STYLE_EXTRACT` instead.
|
|
48
|
+
ENV_PROPAGATION_STYLE_EXTRACT_OLD = 'DD_PROPAGATION_STYLE_EXTRACT'.freeze
|
|
49
|
+
|
|
50
|
+
# A no-op propagator. Compatible with OpenTelemetry's `none` propagator.
|
|
51
|
+
# @see https://opentelemetry.io/docs/concepts/sdk-configuration/general-sdk-configuration/#otel_propagators
|
|
52
|
+
PROPAGATION_STYLE_NONE = 'none'.freeze
|
|
53
|
+
|
|
24
54
|
ENV_X_DATADOG_TAGS_MAX_LENGTH = 'DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH'.freeze
|
|
25
55
|
end
|
|
26
56
|
|