ddtrace 1.7.0 → 1.8.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 +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
@@ -0,0 +1,433 @@
|
|
1
|
+
# typed: false
|
2
|
+
|
3
|
+
require_relative '../../tracing/configuration/ext'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Tracing
|
7
|
+
module Configuration
|
8
|
+
# Configuration settings for tracing.
|
9
|
+
# @public_api
|
10
|
+
# rubocop:disable Metrics/AbcSize
|
11
|
+
# rubocop:disable Metrics/BlockLength
|
12
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
13
|
+
# rubocop:disable Metrics/MethodLength
|
14
|
+
# rubocop:disable Layout/LineLength
|
15
|
+
module Settings
|
16
|
+
def self.extended(base)
|
17
|
+
base.class_eval do
|
18
|
+
# Tracer specific configurations.
|
19
|
+
# @public_api
|
20
|
+
settings :tracing do
|
21
|
+
# Legacy [App Analytics](https://docs.datadoghq.com/tracing/legacy_app_analytics/) configuration.
|
22
|
+
#
|
23
|
+
# @configure_with {Datadog::Tracing}
|
24
|
+
# @deprecated Use [Trace Retention and Ingestion](https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/)
|
25
|
+
# controls.
|
26
|
+
# @public_api
|
27
|
+
settings :analytics do
|
28
|
+
# @default `DD_TRACE_ANALYTICS_ENABLED` environment variable, otherwise `nil`
|
29
|
+
# @return [Boolean,nil]
|
30
|
+
option :enabled do |o|
|
31
|
+
o.default { env_to_bool(Tracing::Configuration::Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED, nil) }
|
32
|
+
o.lazy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# [Distributed Tracing](https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#distributed-tracing) propagation
|
37
|
+
# style configuration.
|
38
|
+
#
|
39
|
+
# The supported formats are:
|
40
|
+
# * `Datadog`: Datadog propagation format, described by [Distributed Tracing](https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#distributed-tracing).
|
41
|
+
# * `b3multi`: B3 Propagation using multiple headers, described by [openzipkin/b3-propagation](https://github.com/openzipkin/b3-propagation#multiple-headers).
|
42
|
+
# * `b3`: B3 Propagation using a single header, described by [openzipkin/b3-propagation](https://github.com/openzipkin/b3-propagation#single-header).
|
43
|
+
#
|
44
|
+
# @public_api
|
45
|
+
settings :distributed_tracing do
|
46
|
+
# An ordered list of what data propagation styles the tracer will use to extract distributed tracing propagation
|
47
|
+
# data from incoming requests and messages.
|
48
|
+
#
|
49
|
+
# The tracer will try to find distributed headers in the order they are present in the list provided to this option.
|
50
|
+
# The first format to have valid data present will be used.
|
51
|
+
#
|
52
|
+
# @default `DD_TRACE_PROPAGATION_STYLE_EXTRACT` environment variable (comma-separated list),
|
53
|
+
# otherwise `['Datadog','b3multi','b3']`.
|
54
|
+
# @return [Array<String>]
|
55
|
+
option :propagation_extract_style do |o|
|
56
|
+
o.default do
|
57
|
+
# DEV-2.0: Change default value to `tracecontext, Datadog`.
|
58
|
+
# Look for all headers by default
|
59
|
+
env_to_list(
|
60
|
+
[
|
61
|
+
Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_EXTRACT,
|
62
|
+
Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_EXTRACT_OLD
|
63
|
+
],
|
64
|
+
[
|
65
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
66
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER,
|
67
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER
|
68
|
+
],
|
69
|
+
comma_separated_only: true
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
o.on_set do |styles|
|
74
|
+
# Modernize B3 options
|
75
|
+
# DEV-2.0: Can be removed with the removal of deprecated B3 constants.
|
76
|
+
styles.map! do |style|
|
77
|
+
case style
|
78
|
+
when Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3
|
79
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER
|
80
|
+
when Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER_OLD
|
81
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER
|
82
|
+
else
|
83
|
+
style
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
o.lazy
|
89
|
+
end
|
90
|
+
|
91
|
+
# The data propagation styles the tracer will use to inject distributed tracing propagation
|
92
|
+
# data into outgoing requests and messages.
|
93
|
+
#
|
94
|
+
# The tracer will inject data from all styles specified in this option.
|
95
|
+
#
|
96
|
+
# @default `DD_TRACE_PROPAGATION_STYLE_INJECT` environment variable (comma-separated list), otherwise `['Datadog']`.
|
97
|
+
# @return [Array<String>]
|
98
|
+
option :propagation_inject_style do |o|
|
99
|
+
o.default do
|
100
|
+
# DEV-2.0: Change default value to `tracecontext, Datadog`.
|
101
|
+
env_to_list(
|
102
|
+
[
|
103
|
+
Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_INJECT,
|
104
|
+
Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_INJECT_OLD
|
105
|
+
],
|
106
|
+
[Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG],
|
107
|
+
comma_separated_only: true # Only inject Datadog headers by default
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
o.on_set do |styles|
|
112
|
+
# Modernize B3 options
|
113
|
+
# DEV-2.0: Can be removed with the removal of deprecated B3 constants.
|
114
|
+
styles.map! do |style|
|
115
|
+
case style
|
116
|
+
when Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3
|
117
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER
|
118
|
+
when Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER_OLD
|
119
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER
|
120
|
+
else
|
121
|
+
style
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
o.lazy
|
127
|
+
end
|
128
|
+
|
129
|
+
# An ordered list of what data propagation styles the tracer will use to extract distributed tracing propagation
|
130
|
+
# data from incoming requests and inject into outgoing requests.
|
131
|
+
#
|
132
|
+
# This configuration is the equivalent of configuring both {propagation_extract_style}
|
133
|
+
# {propagation_inject_style} to value set to {propagation_style}.
|
134
|
+
#
|
135
|
+
# @default `DD_TRACE_PROPAGATION_STYLE` environment variable (comma-separated list).
|
136
|
+
# @return [Array<String>]
|
137
|
+
option :propagation_style do |o|
|
138
|
+
o.default do
|
139
|
+
env_to_list(Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE, nil, comma_separated_only: true)
|
140
|
+
end
|
141
|
+
|
142
|
+
o.on_set do |styles|
|
143
|
+
next unless styles
|
144
|
+
|
145
|
+
# Modernize B3 options
|
146
|
+
# DEV-2.0: Can be removed with the removal of deprecated B3 constants.
|
147
|
+
styles.map! do |style|
|
148
|
+
case style
|
149
|
+
when Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3
|
150
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER
|
151
|
+
when Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER_OLD
|
152
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER
|
153
|
+
else
|
154
|
+
style
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
set_option(:propagation_extract_style, styles)
|
159
|
+
set_option(:propagation_inject_style, styles)
|
160
|
+
end
|
161
|
+
|
162
|
+
o.lazy
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Enable trace collection and span generation.
|
167
|
+
#
|
168
|
+
# You can use this option to disable tracing without having to
|
169
|
+
# remove the library as a whole.
|
170
|
+
#
|
171
|
+
# @default `DD_TRACE_ENABLED` environment variable, otherwise `true`
|
172
|
+
# @return [Boolean]
|
173
|
+
option :enabled do |o|
|
174
|
+
o.default { env_to_bool(Tracing::Configuration::Ext::ENV_ENABLED, true) }
|
175
|
+
o.lazy
|
176
|
+
end
|
177
|
+
|
178
|
+
# A custom tracer instance.
|
179
|
+
#
|
180
|
+
# It must respect the contract of {Datadog::Tracing::Tracer}.
|
181
|
+
# It's recommended to delegate methods to {Datadog::Tracing::Tracer} to ease the implementation
|
182
|
+
# of a custom tracer.
|
183
|
+
#
|
184
|
+
# This option will not return the live tracer instance: it only holds a custom tracing instance, if any.
|
185
|
+
#
|
186
|
+
# For internal use only.
|
187
|
+
#
|
188
|
+
# @default `nil`
|
189
|
+
# @return [Object,nil]
|
190
|
+
option :instance
|
191
|
+
|
192
|
+
# Automatic correlation between tracing and logging.
|
193
|
+
# @see https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#trace-correlation
|
194
|
+
# @return [Boolean]
|
195
|
+
option :log_injection do |o|
|
196
|
+
o.default { env_to_bool(Tracing::Configuration::Ext::Correlation::ENV_LOGS_INJECTION_ENABLED, true) }
|
197
|
+
o.lazy
|
198
|
+
end
|
199
|
+
|
200
|
+
# Configures an alternative trace transport behavior, where
|
201
|
+
# traces can be sent to the agent and backend before all spans
|
202
|
+
# have finished.
|
203
|
+
#
|
204
|
+
# This is useful for long-running jobs or very large traces.
|
205
|
+
#
|
206
|
+
# The trace flame graph will display the partial trace as it is received and constantly
|
207
|
+
# update with new spans as they are flushed.
|
208
|
+
# @public_api
|
209
|
+
settings :partial_flush do
|
210
|
+
# Enable partial trace flushing.
|
211
|
+
#
|
212
|
+
# @default `false`
|
213
|
+
# @return [Boolean]
|
214
|
+
option :enabled, default: false
|
215
|
+
|
216
|
+
# Minimum number of finished spans required in a single unfinished trace before
|
217
|
+
# the tracer will consider that trace for partial flushing.
|
218
|
+
#
|
219
|
+
# This option helps preserve a minimum amount of batching in the
|
220
|
+
# flushing process, reducing network overhead.
|
221
|
+
#
|
222
|
+
# This threshold only applies to unfinished traces. Traces that have finished
|
223
|
+
# are always flushed immediately.
|
224
|
+
#
|
225
|
+
# @default 500
|
226
|
+
# @return [Integer]
|
227
|
+
option :min_spans_threshold, default: 500
|
228
|
+
end
|
229
|
+
|
230
|
+
# Enables {https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/#datadog-intelligent-retention-filter
|
231
|
+
# Datadog intelligent retention filter}.
|
232
|
+
# @default `true`
|
233
|
+
# @return [Boolean,nil]
|
234
|
+
option :priority_sampling
|
235
|
+
|
236
|
+
option :report_hostname do |o|
|
237
|
+
o.default { env_to_bool(Tracing::Configuration::Ext::NET::ENV_REPORT_HOSTNAME, false) }
|
238
|
+
o.lazy
|
239
|
+
end
|
240
|
+
|
241
|
+
# A custom sampler instance.
|
242
|
+
# The object must respect the {Datadog::Tracing::Sampling::Sampler} interface.
|
243
|
+
# @default `nil`
|
244
|
+
# @return [Object,nil]
|
245
|
+
option :sampler
|
246
|
+
|
247
|
+
# Client-side sampling configuration.
|
248
|
+
# @see https://docs.datadoghq.com/tracing/trace_ingestion/mechanisms/
|
249
|
+
# @public_api
|
250
|
+
settings :sampling do
|
251
|
+
# Default sampling rate for the tracer.
|
252
|
+
#
|
253
|
+
# If `nil`, the trace uses an automatic sampling strategy that tries to ensure
|
254
|
+
# the collection of traces that are considered important (e.g. traces with an error, traces
|
255
|
+
# for resources not seen recently).
|
256
|
+
#
|
257
|
+
# @default `DD_TRACE_SAMPLE_RATE` environment variable, otherwise `nil`.
|
258
|
+
# @return [Float,nil]
|
259
|
+
option :default_rate do |o|
|
260
|
+
o.default { env_to_float(Tracing::Configuration::Ext::Sampling::ENV_SAMPLE_RATE, nil) }
|
261
|
+
o.lazy
|
262
|
+
end
|
263
|
+
|
264
|
+
# Rate limit for number of spans per second.
|
265
|
+
#
|
266
|
+
# Spans created above the limit will contribute to service metrics, but won't
|
267
|
+
# have their payload stored.
|
268
|
+
#
|
269
|
+
# @default `DD_TRACE_RATE_LIMIT` environment variable, otherwise 100.
|
270
|
+
# @return [Numeric,nil]
|
271
|
+
option :rate_limit do |o|
|
272
|
+
o.default { env_to_float(Tracing::Configuration::Ext::Sampling::ENV_RATE_LIMIT, 100) }
|
273
|
+
o.lazy
|
274
|
+
end
|
275
|
+
|
276
|
+
# Single span sampling rules.
|
277
|
+
# These rules allow a span to be kept when its encompassing trace is dropped.
|
278
|
+
#
|
279
|
+
# The syntax for single span sampling rules can be found here:
|
280
|
+
# TODO: <Single Span Sampling documentation URL here>
|
281
|
+
#
|
282
|
+
# @default `DD_SPAN_SAMPLING_RULES` environment variable.
|
283
|
+
# Otherwise, `ENV_SPAN_SAMPLING_RULES_FILE` environment variable.
|
284
|
+
# Otherwise `nil`.
|
285
|
+
# @return [String,nil]
|
286
|
+
# @public_api
|
287
|
+
option :span_rules do |o|
|
288
|
+
o.default do
|
289
|
+
rules = ENV[Tracing::Configuration::Ext::Sampling::Span::ENV_SPAN_SAMPLING_RULES]
|
290
|
+
rules_file = ENV[Tracing::Configuration::Ext::Sampling::Span::ENV_SPAN_SAMPLING_RULES_FILE]
|
291
|
+
|
292
|
+
if rules
|
293
|
+
if rules_file
|
294
|
+
Datadog.logger.warn(
|
295
|
+
'Both DD_SPAN_SAMPLING_RULES and DD_SPAN_SAMPLING_RULES_FILE were provided: only ' \
|
296
|
+
'DD_SPAN_SAMPLING_RULES will be used. Please do not provide DD_SPAN_SAMPLING_RULES_FILE when ' \
|
297
|
+
'also providing DD_SPAN_SAMPLING_RULES as their configuration conflicts. ' \
|
298
|
+
"DD_SPAN_SAMPLING_RULES_FILE=#{rules_file} DD_SPAN_SAMPLING_RULES=#{rules}"
|
299
|
+
)
|
300
|
+
end
|
301
|
+
rules
|
302
|
+
elsif rules_file
|
303
|
+
begin
|
304
|
+
File.read(rules_file)
|
305
|
+
rescue => e
|
306
|
+
# `File#read` errors have clear and actionable messages, no need to add extra exception info.
|
307
|
+
Datadog.logger.warn(
|
308
|
+
"Cannot read span sampling rules file `#{rules_file}`: #{e.message}." \
|
309
|
+
'No span sampling rules will be applied.'
|
310
|
+
)
|
311
|
+
nil
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
o.lazy
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
# [Continuous Integration Visibility](https://docs.datadoghq.com/continuous_integration/) configuration.
|
320
|
+
# @public_api
|
321
|
+
settings :test_mode do
|
322
|
+
# Enable test mode. This allows the tracer to collect spans from test runs.
|
323
|
+
#
|
324
|
+
# It also prevents the tracer from collecting spans in a production environment. Only use in a test environment.
|
325
|
+
#
|
326
|
+
# @default `DD_TRACE_TEST_MODE_ENABLED` environment variable, otherwise `false`
|
327
|
+
# @return [Boolean]
|
328
|
+
option :enabled do |o|
|
329
|
+
o.default { env_to_bool(Tracing::Configuration::Ext::Test::ENV_MODE_ENABLED, false) }
|
330
|
+
o.lazy
|
331
|
+
end
|
332
|
+
|
333
|
+
option :trace_flush do |o|
|
334
|
+
o.default { nil }
|
335
|
+
o.lazy
|
336
|
+
end
|
337
|
+
|
338
|
+
option :writer_options do |o|
|
339
|
+
o.default { {} }
|
340
|
+
o.lazy
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
# @see file:docs/GettingStarted.md#configuring-the-transport-layer Configuring the transport layer
|
345
|
+
#
|
346
|
+
# A {Proc} that configures a custom tracer transport.
|
347
|
+
# @yield Receives a {Datadog::Transport::HTTP} that can be modified with custom adapters and settings.
|
348
|
+
# @yieldparam [Datadog::Transport::HTTP] t transport to be configured.
|
349
|
+
# @default `nil`
|
350
|
+
# @return [Proc,nil]
|
351
|
+
option :transport_options, default: nil
|
352
|
+
|
353
|
+
# A custom writer instance.
|
354
|
+
# The object must respect the {Datadog::Tracing::Writer} interface.
|
355
|
+
#
|
356
|
+
# This option is recommended for internal use only.
|
357
|
+
#
|
358
|
+
# @default `nil`
|
359
|
+
# @return [Object,nil]
|
360
|
+
option :writer
|
361
|
+
|
362
|
+
# A custom {Hash} with keyword options to be passed to {Datadog::Tracing::Writer#initialize}.
|
363
|
+
#
|
364
|
+
# This option is recommended for internal use only.
|
365
|
+
#
|
366
|
+
# @default `{}`
|
367
|
+
# @return [Hash,nil]
|
368
|
+
option :writer_options, default: ->(_i) { {} }, lazy: true
|
369
|
+
|
370
|
+
# Client IP configuration
|
371
|
+
# @public_api
|
372
|
+
settings :client_ip do
|
373
|
+
# Whether client IP collection is enabled. When enabled client IPs from HTTP requests will
|
374
|
+
# be reported in traces.
|
375
|
+
#
|
376
|
+
# Usage of the DD_TRACE_CLIENT_IP_HEADER_DISABLED environment variable is deprecated.
|
377
|
+
#
|
378
|
+
# @see https://docs.datadoghq.com/tracing/configure_data_security#configuring-a-client-ip-header
|
379
|
+
#
|
380
|
+
# @default `DD_TRACE_CLIENT_IP_ENABLED` environment variable, otherwise `false`.
|
381
|
+
# @return [Boolean]
|
382
|
+
option :enabled do |o|
|
383
|
+
o.default do
|
384
|
+
disabled = env_to_bool(Tracing::Configuration::Ext::ClientIp::ENV_DISABLED)
|
385
|
+
|
386
|
+
enabled = if disabled.nil?
|
387
|
+
false
|
388
|
+
else
|
389
|
+
Datadog.logger.warn { "#{Tracing::Configuration::Ext::ClientIp::ENV_DISABLED} environment variable is deprecated, found set to #{disabled}, use #{Tracing::Configuration::Ext::ClientIp::ENV_ENABLED}=#{!disabled}" }
|
390
|
+
|
391
|
+
!disabled
|
392
|
+
end
|
393
|
+
|
394
|
+
# ENABLED env var takes precedence over deprecated DISABLED
|
395
|
+
env_to_bool(Tracing::Configuration::Ext::ClientIp::ENV_ENABLED, enabled)
|
396
|
+
end
|
397
|
+
o.lazy
|
398
|
+
end
|
399
|
+
|
400
|
+
# An optional name of a custom header to resolve the client IP from.
|
401
|
+
#
|
402
|
+
# @default `DD_TRACE_CLIENT_IP_HEADER` environment variable, otherwise `nil`.
|
403
|
+
# @return [String,nil]
|
404
|
+
option :header_name do |o|
|
405
|
+
o.default { ENV.fetch(Tracing::Configuration::Ext::ClientIp::ENV_HEADER_NAME, nil) }
|
406
|
+
o.lazy
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
# Maximum size for the `x-datadog-tags` distributed trace tags header.
|
411
|
+
#
|
412
|
+
# If the serialized size of distributed trace tags is larger than this value, it will
|
413
|
+
# not be parsed if incoming, nor exported if outgoing. An error message will be logged
|
414
|
+
# in this case.
|
415
|
+
#
|
416
|
+
# @default `DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH` environment variable, otherwise `512`
|
417
|
+
# @return [Integer]
|
418
|
+
option :x_datadog_tags_max_length do |o|
|
419
|
+
o.default { env_to_int(Tracing::Configuration::Ext::Distributed::ENV_X_DATADOG_TAGS_MAX_LENGTH, 512) }
|
420
|
+
o.lazy
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
# rubocop:enable Metrics/AbcSize
|
427
|
+
# rubocop:enable Metrics/BlockLength
|
428
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
429
|
+
# rubocop:enable Metrics/MethodLength
|
430
|
+
# rubocop:enable Layout/LineLength
|
431
|
+
end
|
432
|
+
end
|
433
|
+
end
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
9
9
|
module Ext
|
10
10
|
ENV_ENABLED = 'DD_TRACE_AWS_ENABLED'.freeze
|
11
|
+
ENV_SERVICE_NAME = 'DD_TRACE_AWS_SERVICE_NAME'.freeze
|
11
12
|
ENV_ANALYTICS_ENABLED = 'DD_TRACE_AWS_ANALYTICS_ENABLED'.freeze
|
12
13
|
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_AWS_ANALYTICS_SAMPLE_RATE'.freeze
|
13
14
|
DEFAULT_PEER_SERVICE_NAME = 'aws'.freeze
|
@@ -10,6 +10,7 @@ module Datadog
|
|
10
10
|
ENV_ENABLED = 'DD_TRACE_DALLI_ENABLED'.freeze
|
11
11
|
ENV_ANALYTICS_ENABLED = 'DD_TRACE_DALLI_ANALYTICS_ENABLED'.freeze
|
12
12
|
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_DALLI_ANALYTICS_SAMPLE_RATE'.freeze
|
13
|
+
ENV_SERVICE_NAME = 'DD_TRACE_DALLI_SERVICE_NAME'.freeze
|
13
14
|
QUANTIZE_MAX_CMD_LENGTH = 100
|
14
15
|
DEFAULT_PEER_SERVICE_NAME = 'memcached'.freeze
|
15
16
|
SPAN_COMMAND = 'memcached.command'.freeze
|
@@ -27,7 +27,11 @@ module Datadog
|
|
27
27
|
end
|
28
28
|
|
29
29
|
option :quantize, default: {}
|
30
|
-
|
30
|
+
|
31
|
+
option :service_name do |o|
|
32
|
+
o.default { ENV.fetch(Ext::ENV_SERVICE_NAME, Ext::DEFAULT_PEER_SERVICE_NAME) }
|
33
|
+
o.lazy
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
9
9
|
module Ext
|
10
10
|
ENV_ENABLED = 'DD_TRACE_ELASTICSEARCH_ENABLED'.freeze
|
11
|
+
ENV_SERVICE_NAME = 'DD_TRACE_ELASTICSEARCH_SERVICE_NAME'.freeze
|
11
12
|
ENV_ANALYTICS_ENABLED = 'DD_TRACE_ELASTICSEARCH_ANALYTICS_ENABLED'.freeze
|
12
13
|
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_ELASTICSEARCH_ANALYTICS_SAMPLE_RATE'.freeze
|
13
14
|
DEFAULT_PEER_SERVICE_NAME = 'elasticsearch'.freeze
|
@@ -27,8 +27,13 @@ module Datadog
|
|
27
27
|
end
|
28
28
|
|
29
29
|
option :distributed_tracing, default: true
|
30
|
-
|
30
|
+
|
31
31
|
option :split_by_domain, default: false
|
32
|
+
|
33
|
+
option :service_name do |o|
|
34
|
+
o.default { ENV.fetch(Ext::ENV_SERVICE_NAME, Ext::DEFAULT_PEER_SERVICE_NAME) }
|
35
|
+
o.lazy
|
36
|
+
end
|
32
37
|
end
|
33
38
|
end
|
34
39
|
end
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
9
9
|
module Ext
|
10
10
|
ENV_ENABLED = 'DD_TRACE_ETHON_ENABLED'.freeze
|
11
|
+
ENV_SERVICE_NAME = 'DD_TRACE_ETHON_SERVICE_NAME'.freeze
|
11
12
|
ENV_ANALYTICS_ENABLED = 'DD_TRACE_ETHON_ANALYTICS_ENABLED'.freeze
|
12
13
|
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_ETHON_ANALYTICS_SAMPLE_RATE'.freeze
|
13
14
|
DEFAULT_PEER_SERVICE_NAME = 'ethon'.freeze
|
@@ -28,8 +28,12 @@ module Datadog
|
|
28
28
|
|
29
29
|
option :distributed_tracing, default: true
|
30
30
|
option :error_handler
|
31
|
-
option :service_name, default: Ext::DEFAULT_PEER_SERVICE_NAME
|
32
31
|
option :split_by_domain, default: false
|
32
|
+
|
33
|
+
option :service_name do |o|
|
34
|
+
o.default { ENV.fetch(Ext::ENV_SERVICE_NAME, Ext::DEFAULT_PEER_SERVICE_NAME) }
|
35
|
+
o.lazy
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
9
9
|
module Ext
|
10
10
|
ENV_ENABLED = 'DD_TRACE_EXCON_ENABLED'.freeze
|
11
|
+
ENV_SERVICE_NAME = 'DD_TRACE_EXCON_SERVICE_NAME'.freeze
|
11
12
|
ENV_ANALYTICS_ENABLED = 'DD_TRACE_EXCON_ANALYTICS_ENABLED'.freeze
|
12
13
|
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_EXCON_ANALYTICS_SAMPLE_RATE'.freeze
|
13
14
|
DEFAULT_PEER_SERVICE_NAME = 'excon'.freeze
|
@@ -32,8 +32,12 @@ module Datadog
|
|
32
32
|
|
33
33
|
option :distributed_tracing, default: true
|
34
34
|
option :error_handler, default: DEFAULT_ERROR_HANDLER
|
35
|
-
option :service_name, default: Ext::DEFAULT_PEER_SERVICE_NAME
|
36
35
|
option :split_by_domain, default: false
|
36
|
+
|
37
|
+
option :service_name do |o|
|
38
|
+
o.default { ENV.fetch(Ext::ENV_SERVICE_NAME, Ext::DEFAULT_PEER_SERVICE_NAME) }
|
39
|
+
o.lazy
|
40
|
+
end
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
9
9
|
module Ext
|
10
10
|
ENV_ENABLED = 'DD_TRACE_FARADAY_ENABLED'.freeze
|
11
|
+
ENV_SERVICE_NAME = 'DD_TRACE_FARADAY_SERVICE_NAME'.freeze
|
11
12
|
ENV_ANALYTICS_ENABLED = 'DD_TRACE_FARADAY_ANALYTICS_ENABLED'.freeze
|
12
13
|
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_FARADAY_ANALYTICS_SAMPLE_RATE'.freeze
|
13
14
|
DEFAULT_PEER_SERVICE_NAME = 'faraday'.freeze
|
@@ -28,7 +28,12 @@ module Datadog
|
|
28
28
|
end
|
29
29
|
|
30
30
|
option :distributed_tracing, default: true
|
31
|
-
|
31
|
+
|
32
|
+
option :service_name do |o|
|
33
|
+
o.default { ENV.fetch(Ext::ENV_SERVICE_NAME, Ext::DEFAULT_PEER_SERVICE_NAME) }
|
34
|
+
o.lazy
|
35
|
+
end
|
36
|
+
|
32
37
|
option :error_handler, default: Tracing::SpanOperation::Events::DEFAULT_ON_ERROR
|
33
38
|
end
|
34
39
|
end
|
@@ -2,10 +2,12 @@
|
|
2
2
|
# typed: true
|
3
3
|
|
4
4
|
require_relative 'fetcher'
|
5
|
-
require_relative '../../../distributed/
|
5
|
+
require_relative '../../../distributed/b3_multi'
|
6
6
|
require_relative '../../../distributed/b3_single'
|
7
7
|
require_relative '../../../distributed/datadog'
|
8
|
+
require_relative '../../../distributed/none'
|
8
9
|
require_relative '../../../distributed/propagation'
|
10
|
+
require_relative '../../../distributed/trace_context'
|
9
11
|
|
10
12
|
module Datadog
|
11
13
|
module Tracing
|
@@ -18,12 +20,15 @@ module Datadog
|
|
18
20
|
def initialize
|
19
21
|
super(
|
20
22
|
propagation_styles: {
|
21
|
-
Tracing::Configuration::Ext::Distributed::
|
22
|
-
Tracing::Distributed::
|
23
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER =>
|
24
|
+
Tracing::Distributed::B3Multi.new(fetcher: Fetcher),
|
23
25
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER =>
|
24
26
|
Tracing::Distributed::B3Single.new(fetcher: Fetcher),
|
25
27
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG =>
|
26
|
-
Tracing::Distributed::Datadog.new(fetcher: Fetcher)
|
28
|
+
Tracing::Distributed::Datadog.new(fetcher: Fetcher),
|
29
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT =>
|
30
|
+
Tracing::Distributed::TraceContext.new(fetcher: Fetcher),
|
31
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_NONE => Tracing::Distributed::None.new
|
27
32
|
})
|
28
33
|
end
|
29
34
|
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
9
9
|
module Ext
|
10
10
|
ENV_ENABLED = 'DD_TRACE_GRPC_ENABLED'.freeze
|
11
|
+
ENV_SERVICE_NAME = 'DD_TRACE_GRPC_SERVICE_NAME'.freeze
|
11
12
|
ENV_ANALYTICS_ENABLED = 'DD_TRACE_GRPC_ANALYTICS_ENABLED'.freeze
|
12
13
|
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_GRPC_ANALYTICS_SAMPLE_RATE'.freeze
|
13
14
|
DEFAULT_PEER_SERVICE_NAME = 'grpc'.freeze
|
@@ -27,7 +27,12 @@ module Datadog
|
|
27
27
|
end
|
28
28
|
|
29
29
|
option :distributed_tracing, default: true
|
30
|
-
|
30
|
+
|
31
|
+
option :service_name do |o|
|
32
|
+
o.default { ENV.fetch(Ext::ENV_SERVICE_NAME, Ext::DEFAULT_PEER_SERVICE_NAME) }
|
33
|
+
o.lazy
|
34
|
+
end
|
35
|
+
|
31
36
|
option :split_by_domain, default: false
|
32
37
|
end
|
33
38
|
end
|