datadog 2.12.2 → 2.15.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 +74 -2
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +16 -14
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +3 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.c +69 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.h +7 -0
- data/ext/datadog_profiling_native_extension/http_transport.c +25 -32
- data/ext/datadog_profiling_native_extension/profiling.c +2 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.c +22 -21
- data/ext/libdatadog_api/datadog_ruby_common.h +3 -0
- data/lib/datadog/appsec/actions_handler/serializable_backtrace.rb +89 -0
- data/lib/datadog/appsec/actions_handler.rb +22 -1
- data/lib/datadog/appsec/anonymizer.rb +16 -0
- data/lib/datadog/appsec/assets/waf_rules/README.md +50 -5
- data/lib/datadog/appsec/assets/waf_rules/processors.json +239 -10
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +0 -1344
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +926 -17
- data/lib/datadog/appsec/assets/waf_rules/strict.json +0 -1344
- data/lib/datadog/appsec/component.rb +19 -17
- data/lib/datadog/appsec/compressed_json.rb +40 -0
- data/lib/datadog/appsec/configuration/settings.rb +62 -10
- data/lib/datadog/appsec/contrib/active_record/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +7 -31
- data/lib/datadog/appsec/contrib/devise/data_extractor.rb +79 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +21 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +0 -1
- data/lib/datadog/appsec/contrib/devise/patcher.rb +36 -23
- data/lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb +102 -0
- data/lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb +69 -0
- data/lib/datadog/appsec/contrib/devise/{patcher/rememberable_patch.rb → patches/skip_signin_tracking_patch.rb} +2 -2
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +93 -0
- data/lib/datadog/appsec/contrib/rack/ext.rb +14 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +10 -3
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +0 -2
- data/lib/datadog/appsec/event.rb +22 -51
- data/lib/datadog/appsec/ext.rb +4 -2
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +4 -2
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +8 -3
- data/lib/datadog/appsec/remote.rb +4 -0
- data/lib/datadog/appsec/security_engine/runner.rb +2 -2
- data/lib/datadog/appsec/utils.rb +0 -2
- data/lib/datadog/core/configuration/components.rb +2 -1
- data/lib/datadog/core/configuration/ext.rb +4 -0
- data/lib/datadog/core/configuration/options.rb +2 -2
- data/lib/datadog/core/configuration/settings.rb +53 -30
- data/lib/datadog/core/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/core/environment/agent_info.rb +4 -3
- data/lib/datadog/core/metrics/client.rb +1 -1
- data/lib/datadog/core/remote/client.rb +1 -1
- data/lib/datadog/core/remote/component.rb +3 -6
- data/lib/datadog/core/remote/configuration/repository.rb +2 -1
- data/lib/datadog/core/remote/negotiation.rb +9 -9
- data/lib/datadog/core/remote/transport/config.rb +4 -3
- data/lib/datadog/core/remote/transport/http/client.rb +4 -3
- data/lib/datadog/core/remote/transport/http/config.rb +6 -32
- data/lib/datadog/core/remote/transport/http/negotiation.rb +6 -32
- data/lib/datadog/core/remote/transport/http.rb +22 -57
- data/lib/datadog/core/remote/transport/negotiation.rb +4 -3
- data/lib/datadog/core/runtime/metrics.rb +8 -1
- data/lib/datadog/core/telemetry/http/adapters/net.rb +1 -1
- data/lib/datadog/core/telemetry/metric.rb +5 -5
- data/lib/datadog/core/telemetry/request.rb +1 -1
- data/lib/datadog/core/transport/http/api/instance.rb +17 -0
- data/lib/datadog/core/transport/http/api/spec.rb +17 -0
- data/lib/datadog/core/transport/http/builder.rb +5 -3
- data/lib/datadog/core/transport/http.rb +39 -2
- data/lib/datadog/di/component.rb +0 -2
- data/lib/datadog/di/probe_notification_builder.rb +1 -1
- data/lib/datadog/di/probe_notifier_worker.rb +16 -16
- data/lib/datadog/di/transport/diagnostics.rb +4 -3
- data/lib/datadog/di/transport/http/api.rb +2 -12
- data/lib/datadog/di/transport/http/client.rb +4 -3
- data/lib/datadog/di/transport/http/diagnostics.rb +7 -34
- data/lib/datadog/di/transport/http/input.rb +7 -34
- data/lib/datadog/di/transport/http.rb +14 -62
- data/lib/datadog/di/transport/input.rb +4 -3
- data/lib/datadog/di/utils.rb +5 -0
- data/lib/datadog/kit/appsec/events.rb +12 -0
- data/lib/datadog/kit/identity.rb +5 -1
- data/lib/datadog/opentelemetry/api/baggage.rb +90 -0
- data/lib/datadog/opentelemetry/api/baggage.rbs +26 -0
- data/lib/datadog/opentelemetry/api/context.rb +16 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/datadog/opentelemetry.rb +2 -1
- data/lib/datadog/profiling/collectors/info.rb +3 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +1 -1
- data/lib/datadog/profiling/encoded_profile.rb +11 -0
- data/lib/datadog/profiling/exporter.rb +2 -3
- data/lib/datadog/profiling/ext.rb +0 -1
- data/lib/datadog/profiling/flush.rb +4 -7
- data/lib/datadog/profiling/http_transport.rb +10 -59
- data/lib/datadog/profiling/stack_recorder.rb +4 -4
- data/lib/datadog/profiling.rb +6 -2
- data/lib/datadog/tracing/component.rb +15 -12
- data/lib/datadog/tracing/configuration/ext.rb +7 -1
- data/lib/datadog/tracing/configuration/settings.rb +18 -2
- data/lib/datadog/tracing/context_provider.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/integration.rb +1 -1
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +4 -5
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +7 -1
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +0 -15
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +4 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -5
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +5 -11
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +6 -10
- data/lib/datadog/tracing/contrib/karafka/configuration/settings.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/distributed/propagation.rb +46 -0
- data/lib/datadog/tracing/contrib/karafka/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/karafka/monitor.rb +66 -0
- data/lib/datadog/tracing/contrib/karafka/patcher.rb +71 -0
- data/lib/datadog/tracing/contrib/karafka.rb +37 -0
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +17 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +9 -0
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +5 -1
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +5 -3
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +6 -1
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +1 -1
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/correlation.rb +9 -2
- data/lib/datadog/tracing/distributed/baggage.rb +131 -0
- data/lib/datadog/tracing/distributed/datadog.rb +2 -0
- data/lib/datadog/tracing/distributed/propagation.rb +25 -4
- data/lib/datadog/tracing/distributed/propagation_policy.rb +42 -0
- data/lib/datadog/tracing/metadata/ext.rb +5 -0
- data/lib/datadog/tracing/sampling/span/rule.rb +0 -1
- data/lib/datadog/tracing/span_event.rb +1 -1
- data/lib/datadog/tracing/span_operation.rb +2 -1
- data/lib/datadog/tracing/sync_writer.rb +1 -2
- data/lib/datadog/tracing/trace_digest.rb +9 -2
- data/lib/datadog/tracing/trace_operation.rb +29 -17
- data/lib/datadog/tracing/trace_segment.rb +6 -4
- data/lib/datadog/tracing/tracer.rb +38 -2
- data/lib/datadog/tracing/transport/http/api.rb +2 -10
- data/lib/datadog/tracing/transport/http/client.rb +5 -4
- data/lib/datadog/tracing/transport/http/traces.rb +13 -41
- data/lib/datadog/tracing/transport/http.rb +11 -44
- data/lib/datadog/tracing/transport/trace_formatter.rb +7 -0
- data/lib/datadog/tracing/transport/traces.rb +26 -9
- data/lib/datadog/tracing/workers/trace_writer.rb +2 -6
- data/lib/datadog/tracing/writer.rb +2 -6
- data/lib/datadog/tracing.rb +16 -3
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +1 -1
- metadata +28 -13
- data/lib/datadog/appsec/contrib/devise/event.rb +0 -54
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +0 -72
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +0 -47
- data/lib/datadog/appsec/contrib/devise/resource.rb +0 -35
- data/lib/datadog/appsec/contrib/devise/tracking.rb +0 -57
- data/lib/datadog/appsec/utils/trace_operation.rb +0 -15
@@ -9,10 +9,9 @@ module Datadog
|
|
9
9
|
attr_reader \
|
10
10
|
:start,
|
11
11
|
:finish,
|
12
|
-
:
|
13
|
-
:pprof_data, # gzipped pprof bytes
|
12
|
+
:encoded_profile,
|
14
13
|
:code_provenance_file_name,
|
15
|
-
:code_provenance_data,
|
14
|
+
:code_provenance_data,
|
16
15
|
:tags_as_array,
|
17
16
|
:internal_metadata_json,
|
18
17
|
:info_json
|
@@ -20,8 +19,7 @@ module Datadog
|
|
20
19
|
def initialize(
|
21
20
|
start:,
|
22
21
|
finish:,
|
23
|
-
|
24
|
-
pprof_data:,
|
22
|
+
encoded_profile:,
|
25
23
|
code_provenance_file_name:,
|
26
24
|
code_provenance_data:,
|
27
25
|
tags_as_array:,
|
@@ -30,8 +28,7 @@ module Datadog
|
|
30
28
|
)
|
31
29
|
@start = start
|
32
30
|
@finish = finish
|
33
|
-
@
|
34
|
-
@pprof_data = pprof_data
|
31
|
+
@encoded_profile = encoded_profile
|
35
32
|
@code_provenance_file_name = code_provenance_file_name
|
36
33
|
@code_provenance_data = code_provenance_data
|
37
34
|
@tags_as_array = tags_as_array
|
@@ -20,34 +20,21 @@ module Datadog
|
|
20
20
|
[:agent, agent_settings.url].freeze
|
21
21
|
end
|
22
22
|
|
23
|
-
status, result =
|
23
|
+
status, result = self.class._native_validate_exporter(exporter_configuration)
|
24
24
|
|
25
25
|
raise(ArgumentError, "Failed to initialize transport: #{result}") if status == :error
|
26
26
|
end
|
27
27
|
|
28
28
|
def export(flush)
|
29
|
-
status, result =
|
30
|
-
exporter_configuration
|
31
|
-
|
32
|
-
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
start_timespec_nanoseconds: flush.start.tv_nsec,
|
39
|
-
finish_timespec_seconds: flush.finish.tv_sec,
|
40
|
-
finish_timespec_nanoseconds: flush.finish.tv_nsec,
|
41
|
-
|
42
|
-
pprof_file_name: flush.pprof_file_name,
|
43
|
-
pprof_data: flush.pprof_data,
|
44
|
-
code_provenance_file_name: flush.code_provenance_file_name,
|
45
|
-
code_provenance_data: flush.code_provenance_data,
|
46
|
-
|
47
|
-
tags_as_array: flush.tags_as_array,
|
48
|
-
internal_metadata_json: flush.internal_metadata_json,
|
49
|
-
|
50
|
-
info_json: flush.info_json
|
29
|
+
status, result = self.class._native_do_export(
|
30
|
+
exporter_configuration,
|
31
|
+
@upload_timeout_milliseconds,
|
32
|
+
flush,
|
33
|
+
# TODO: This is going to be removed once we move to libdatadog 17
|
34
|
+
flush.start.tv_sec,
|
35
|
+
flush.start.tv_nsec,
|
36
|
+
flush.finish.tv_sec,
|
37
|
+
flush.finish.tv_nsec,
|
51
38
|
)
|
52
39
|
|
53
40
|
if status == :ok
|
@@ -77,42 +64,6 @@ module Datadog
|
|
77
64
|
site && api_key && Core::Environment::VariableHelpers.env_to_bool(Profiling::Ext::ENV_AGENTLESS, false)
|
78
65
|
end
|
79
66
|
|
80
|
-
def validate_exporter(exporter_configuration)
|
81
|
-
self.class._native_validate_exporter(exporter_configuration)
|
82
|
-
end
|
83
|
-
|
84
|
-
def do_export(
|
85
|
-
exporter_configuration:,
|
86
|
-
upload_timeout_milliseconds:,
|
87
|
-
start_timespec_seconds:,
|
88
|
-
start_timespec_nanoseconds:,
|
89
|
-
finish_timespec_seconds:,
|
90
|
-
finish_timespec_nanoseconds:,
|
91
|
-
pprof_file_name:,
|
92
|
-
pprof_data:,
|
93
|
-
code_provenance_file_name:,
|
94
|
-
code_provenance_data:,
|
95
|
-
tags_as_array:,
|
96
|
-
internal_metadata_json:,
|
97
|
-
info_json:
|
98
|
-
)
|
99
|
-
self.class._native_do_export(
|
100
|
-
exporter_configuration,
|
101
|
-
upload_timeout_milliseconds,
|
102
|
-
start_timespec_seconds,
|
103
|
-
start_timespec_nanoseconds,
|
104
|
-
finish_timespec_seconds,
|
105
|
-
finish_timespec_nanoseconds,
|
106
|
-
pprof_file_name,
|
107
|
-
pprof_data,
|
108
|
-
code_provenance_file_name,
|
109
|
-
code_provenance_data,
|
110
|
-
tags_as_array,
|
111
|
-
internal_metadata_json,
|
112
|
-
info_json,
|
113
|
-
)
|
114
|
-
end
|
115
|
-
|
116
67
|
def config_without_api_key
|
117
68
|
"#{exporter_configuration[0]}: #{exporter_configuration[1]}"
|
118
69
|
end
|
@@ -63,11 +63,11 @@ module Datadog
|
|
63
63
|
status, result = @no_concurrent_synchronize_mutex.synchronize { self.class._native_serialize(self) }
|
64
64
|
|
65
65
|
if status == :ok
|
66
|
-
start, finish,
|
66
|
+
start, finish, encoded_profile, profile_stats = result
|
67
67
|
|
68
68
|
Datadog.logger.debug { "Encoded profile covering #{start.iso8601} to #{finish.iso8601}" }
|
69
69
|
|
70
|
-
[start, finish,
|
70
|
+
[start, finish, encoded_profile, profile_stats]
|
71
71
|
else
|
72
72
|
error_message = result
|
73
73
|
|
@@ -82,9 +82,9 @@ module Datadog
|
|
82
82
|
status, result = @no_concurrent_synchronize_mutex.synchronize { self.class._native_serialize(self) }
|
83
83
|
|
84
84
|
if status == :ok
|
85
|
-
_start, _finish,
|
85
|
+
_start, _finish, encoded_profile = result
|
86
86
|
|
87
|
-
|
87
|
+
encoded_profile
|
88
88
|
else
|
89
89
|
error_message = result
|
90
90
|
|
data/lib/datadog/profiling.rb
CHANGED
@@ -78,8 +78,11 @@ module Datadog
|
|
78
78
|
end
|
79
79
|
|
80
80
|
private_class_method def self.replace_noop_allocation_count
|
81
|
-
|
82
|
-
|
81
|
+
class << self
|
82
|
+
remove_method :allocation_count
|
83
|
+
def allocation_count
|
84
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_allocation_count
|
85
|
+
end
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
@@ -146,6 +149,7 @@ module Datadog
|
|
146
149
|
require_relative 'profiling/collectors/thread_context'
|
147
150
|
require_relative 'profiling/stack_recorder'
|
148
151
|
require_relative 'profiling/exporter'
|
152
|
+
require_relative 'profiling/encoded_profile'
|
149
153
|
require_relative 'profiling/flush'
|
150
154
|
require_relative 'profiling/scheduler'
|
151
155
|
require_relative 'profiling/tasks/setup'
|
@@ -6,6 +6,7 @@ require_relative 'sync_writer'
|
|
6
6
|
require_relative 'sampling/span/rule_parser'
|
7
7
|
require_relative 'sampling/span/sampler'
|
8
8
|
require_relative 'diagnostics/environment_logger'
|
9
|
+
require_relative 'contrib/component'
|
9
10
|
|
10
11
|
module Datadog
|
11
12
|
module Tracing
|
@@ -74,18 +75,11 @@ module Datadog
|
|
74
75
|
return sampler
|
75
76
|
end
|
76
77
|
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
|
82
|
-
if settings.appsec.standalone.enabled
|
83
|
-
post_sampler = Tracing::Sampling::RuleSampler.new(
|
84
|
-
[Tracing::Sampling::SimpleRule.new(sample_rate: 1.0)],
|
85
|
-
rate_limiter: Datadog::Core::TokenBucket.new(1.0 / 60, 1.0),
|
86
|
-
default_sample_rate: 1.0 / 60
|
87
|
-
)
|
88
|
-
end
|
78
|
+
# APM Disablement means that we don't want to send traces that only contains APM data.
|
79
|
+
# Other products can then put the sampling priority to MANUAL_KEEP if they want to keep traces.
|
80
|
+
# (e.g.: AppSec will MANUAL_KEEP traces with AppSec events) and clients will be billed only for those traces.
|
81
|
+
# But to keep the service alive on the backend side, we need to send one trace per minute.
|
82
|
+
post_sampler = build_rate_limit_post_sampler(seconds: 60) unless settings.apm.tracing.enabled
|
89
83
|
|
90
84
|
# Sampling rules are provided
|
91
85
|
if (rules = settings.tracing.sampling.rules)
|
@@ -197,6 +191,15 @@ module Datadog
|
|
197
191
|
end
|
198
192
|
end
|
199
193
|
|
194
|
+
# Build a post-sampler that limits the rate of traces to one per `seconds`.
|
195
|
+
# E.g.: `build_rate_limit_post_sampler(seconds: 60)` will limit the rate to one trace per minute.
|
196
|
+
def build_rate_limit_post_sampler(seconds:)
|
197
|
+
Tracing::Sampling::RuleSampler.new(
|
198
|
+
rate_limiter: Datadog::Core::TokenBucket.new(1.0 / seconds, 1.0),
|
199
|
+
default_sample_rate: 1.0
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
200
203
|
def build_test_mode_trace_flush(settings)
|
201
204
|
# If context flush behavior is provided, use it instead.
|
202
205
|
settings.tracing.test_mode.trace_flush || build_trace_flush(settings)
|
@@ -12,6 +12,7 @@ module Datadog
|
|
12
12
|
ENV_OTEL_TRACES_EXPORTER = 'OTEL_TRACES_EXPORTER'
|
13
13
|
ENV_HEADER_TAGS = 'DD_TRACE_HEADER_TAGS'
|
14
14
|
ENV_TRACE_ID_128_BIT_GENERATION_ENABLED = 'DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED'
|
15
|
+
ENV_NATIVE_SPAN_EVENTS = 'DD_TRACE_NATIVE_SPAN_EVENTS'
|
15
16
|
|
16
17
|
# @public_api
|
17
18
|
module SpanAttributeSchema
|
@@ -41,8 +42,13 @@ module Datadog
|
|
41
42
|
# W3C Trace Context
|
42
43
|
PROPAGATION_STYLE_TRACE_CONTEXT = 'tracecontext'
|
43
44
|
|
45
|
+
# W3C Baggage
|
46
|
+
# @see https://www.w3.org/TR/baggage/
|
47
|
+
PROPAGATION_STYLE_BAGGAGE = 'baggage'
|
48
|
+
|
44
49
|
PROPAGATION_STYLE_SUPPORTED = [PROPAGATION_STYLE_DATADOG, PROPAGATION_STYLE_B3_MULTI_HEADER,
|
45
|
-
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT
|
50
|
+
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT,
|
51
|
+
PROPAGATION_STYLE_BAGGAGE].freeze
|
46
52
|
|
47
53
|
# Sets both extract and inject propagation style tho the provided value.
|
48
54
|
# Has lower precedence than `DD_TRACE_PROPAGATION_STYLE_INJECT` or
|
@@ -42,7 +42,7 @@ module Datadog
|
|
42
42
|
#
|
43
43
|
# The tracer will try to find distributed headers in the order they are present in the list provided to this option.
|
44
44
|
# The first format to have valid data present will be used.
|
45
|
-
#
|
45
|
+
# Baggage style is a special case, as it will always be extracted in addition if present.
|
46
46
|
# @default `DD_TRACE_PROPAGATION_STYLE_EXTRACT` environment variable (comma-separated list),
|
47
47
|
# otherwise `['datadog','b3multi','b3']`.
|
48
48
|
# @return [Array<String>]
|
@@ -53,6 +53,7 @@ module Datadog
|
|
53
53
|
[
|
54
54
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
55
55
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT,
|
56
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE,
|
56
57
|
]
|
57
58
|
)
|
58
59
|
o.after_set do |styles|
|
@@ -74,6 +75,7 @@ module Datadog
|
|
74
75
|
o.default [
|
75
76
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
76
77
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT,
|
78
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE,
|
77
79
|
]
|
78
80
|
o.after_set do |styles|
|
79
81
|
# Make values case-insensitive
|
@@ -186,7 +188,7 @@ module Datadog
|
|
186
188
|
# It is not supported by our backend yet. Do not enable it.
|
187
189
|
option :trace_id_128_bit_logging_enabled do |o|
|
188
190
|
o.env Tracing::Configuration::Ext::Correlation::ENV_TRACE_ID_128_BIT_LOGGING_ENABLED
|
189
|
-
o.default
|
191
|
+
o.default true
|
190
192
|
o.type :bool
|
191
193
|
end
|
192
194
|
|
@@ -249,6 +251,20 @@ module Datadog
|
|
249
251
|
o.type :bool
|
250
252
|
end
|
251
253
|
|
254
|
+
# Forces the tracer to always send span events with the native span events format
|
255
|
+
# regardless of the agent support. This is useful in agent-less setups.
|
256
|
+
#
|
257
|
+
# When set to `nil`, the default, the agent will be queried for
|
258
|
+
# native span events support.
|
259
|
+
#
|
260
|
+
# @default `DD_TRACE_NATIVE_SPAN_EVENTS` environment variable, otherwise `false`
|
261
|
+
# @return [Boolean,nil]
|
262
|
+
option :native_span_events do |o|
|
263
|
+
o.env Tracing::Configuration::Ext::ENV_NATIVE_SPAN_EVENTS
|
264
|
+
o.default nil
|
265
|
+
o.type :bool, nilable: true
|
266
|
+
end
|
267
|
+
|
252
268
|
# A custom sampler instance.
|
253
269
|
# The object must respect the {Datadog::Tracing::Sampling::Sampler} interface.
|
254
270
|
# @default `nil`
|
@@ -49,7 +49,7 @@ module Datadog
|
|
49
49
|
# To support multiple tracers simultaneously, each {Datadog::Tracing::FiberLocalContext}
|
50
50
|
# instance has its own fiber-local variable.
|
51
51
|
def initialize
|
52
|
-
@key = "datadog_context_#{FiberLocalContext.next_instance_id}"
|
52
|
+
@key = :"datadog_context_#{FiberLocalContext.next_instance_id}"
|
53
53
|
|
54
54
|
self.local = Context.new
|
55
55
|
end
|
@@ -110,11 +110,10 @@ module Datadog
|
|
110
110
|
|
111
111
|
datadog_tag_request
|
112
112
|
|
113
|
-
if
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
if datadog_configuration[:distributed_tracing]
|
113
|
+
if Tracing::Distributed::PropagationPolicy.enabled?(
|
114
|
+
global_config: datadog_configuration,
|
115
|
+
trace: datadog_trace
|
116
|
+
)
|
118
117
|
@datadog_original_headers ||= {}
|
119
118
|
Contrib::HTTP.inject(datadog_trace, @datadog_original_headers)
|
120
119
|
self.headers = @datadog_original_headers
|
@@ -30,10 +30,12 @@ module Datadog
|
|
30
30
|
trace = Tracing.active_trace
|
31
31
|
datum[:datadog_span] = span
|
32
32
|
annotate!(span, datum)
|
33
|
-
if
|
34
|
-
|
33
|
+
if Tracing::Distributed::PropagationPolicy.enabled?(
|
34
|
+
global_config: @options,
|
35
|
+
trace: trace
|
36
|
+
)
|
37
|
+
propagate!(trace, span, datum)
|
35
38
|
end
|
36
|
-
propagate!(trace, span, datum) if distributed_tracing?
|
37
39
|
|
38
40
|
span
|
39
41
|
end
|
@@ -48,6 +48,7 @@ module Datadog
|
|
48
48
|
|
49
49
|
module Messaging
|
50
50
|
TAG_SYSTEM = 'messaging.system'
|
51
|
+
TAG_DESTINATION = 'messaging.destination'
|
51
52
|
PEER_SERVICE_SOURCES = Array[Tracing::Metadata::Ext::NET::TAG_DESTINATION_NAME,
|
52
53
|
Tracing::Metadata::Ext::TAG_PEER_HOSTNAME,
|
53
54
|
Tracing::Metadata::Ext::NET::TAG_TARGET_HOST,].freeze
|
@@ -29,10 +29,12 @@ module Datadog
|
|
29
29
|
|
30
30
|
Tracing.trace(Ext::SPAN_REQUEST, on_error: request_options[:on_error]) do |span, trace|
|
31
31
|
annotate!(span, env, request_options)
|
32
|
-
if
|
33
|
-
|
32
|
+
if Tracing::Distributed::PropagationPolicy.enabled?(
|
33
|
+
global_config: request_options,
|
34
|
+
trace: trace
|
35
|
+
)
|
36
|
+
propagate!(trace, span, env)
|
34
37
|
end
|
35
|
-
propagate!(trace, span, env) if request_options[:distributed_tracing] && Tracing.enabled?
|
36
38
|
app.call(env).on_complete { |resp| handle_response(span, resp, request_options) }
|
37
39
|
end
|
38
40
|
end
|
@@ -81,7 +81,13 @@ module Datadog
|
|
81
81
|
# Set analytics sample rate
|
82
82
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
83
83
|
|
84
|
-
|
84
|
+
if Tracing::Distributed::PropagationPolicy.enabled?(
|
85
|
+
pin_config: Datadog.configuration_for(self),
|
86
|
+
global_config: datadog_configuration,
|
87
|
+
trace: trace
|
88
|
+
)
|
89
|
+
GRPC.inject(trace, metadata)
|
90
|
+
end
|
85
91
|
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
86
92
|
rescue StandardError => e
|
87
93
|
Datadog.logger.debug("GRPC client trace failed: #{e}")
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'fetcher'
|
4
4
|
require_relative '../../../distributed/b3_multi'
|
5
5
|
require_relative '../../../distributed/b3_single'
|
6
|
+
require_relative '../../../distributed/propagation_policy'
|
6
7
|
require_relative '../../../distributed/datadog'
|
7
8
|
require_relative '../../../distributed/none'
|
8
9
|
require_relative '../../../distributed/propagation'
|
@@ -31,6 +32,8 @@ module Datadog
|
|
31
32
|
Tracing::Distributed::Datadog.new(fetcher: Fetcher),
|
32
33
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT =>
|
33
34
|
Tracing::Distributed::TraceContext.new(fetcher: Fetcher),
|
35
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE =>
|
36
|
+
Tracing::Distributed::Baggage.new(fetcher: Fetcher),
|
34
37
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_NONE => Tracing::Distributed::None.new
|
35
38
|
},
|
36
39
|
propagation_style_inject: propagation_style_inject,
|
@@ -27,21 +27,6 @@ module Datadog
|
|
27
27
|
!!(request[Datadog::Core::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION] ||
|
28
28
|
request[Datadog::Core::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST])
|
29
29
|
end
|
30
|
-
|
31
|
-
def should_skip_distributed_tracing?(client_config)
|
32
|
-
if Datadog.configuration.appsec.standalone.enabled
|
33
|
-
# Skip distributed tracing so that we don't bill distributed traces in case of absence of
|
34
|
-
# upstream ASM event (_dd.p.appsec:1) and no local security event (which sets _dd.p.appsec:1 locally).
|
35
|
-
# If there is an ASM event, we still have to check if distributed tracing is enabled or not
|
36
|
-
return true unless Tracing.active_trace
|
37
|
-
|
38
|
-
return true if Tracing.active_trace.get_tag(Datadog::AppSec::Ext::TAG_DISTRIBUTED_APPSEC_EVENT) != '1'
|
39
|
-
end
|
40
|
-
|
41
|
-
return !client_config[:distributed_tracing] if client_config && client_config.key?(:distributed_tracing)
|
42
|
-
|
43
|
-
!Datadog.configuration.tracing[:http][:distributed_tracing]
|
44
|
-
end
|
45
30
|
end
|
46
31
|
end
|
47
32
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'fetcher'
|
4
4
|
require_relative '../../../distributed/propagation'
|
5
|
+
require_relative '../../../distributed/propagation_policy'
|
5
6
|
require_relative '../../../distributed/b3_multi'
|
6
7
|
require_relative '../../../distributed/b3_single'
|
7
8
|
require_relative '../../../distributed/datadog'
|
@@ -30,7 +31,9 @@ module Datadog
|
|
30
31
|
Tracing::Distributed::Datadog.new(fetcher: Fetcher),
|
31
32
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT =>
|
32
33
|
Tracing::Distributed::TraceContext.new(fetcher: Fetcher),
|
33
|
-
Tracing::Configuration::Ext::Distributed::
|
34
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE =>
|
35
|
+
Tracing::Distributed::Baggage.new(fetcher: Fetcher),
|
36
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_NONE => Tracing::Distributed::None.new,
|
34
37
|
},
|
35
38
|
propagation_style_inject: propagation_style_inject,
|
36
39
|
propagation_style_extract: propagation_style_extract,
|
@@ -35,11 +35,11 @@ module Datadog
|
|
35
35
|
span.type = Tracing::Metadata::Ext::HTTP::TYPE_OUTBOUND
|
36
36
|
span.resource = req.method
|
37
37
|
|
38
|
-
if
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
if Tracing::Distributed::PropagationPolicy.enabled?(
|
39
|
+
pin_config: client_config,
|
40
|
+
global_config: Datadog.configuration.tracing[:http],
|
41
|
+
trace: trace
|
42
|
+
)
|
43
43
|
Contrib::HTTP.inject(trace, req)
|
44
44
|
end
|
45
45
|
|
@@ -30,11 +30,11 @@ module Datadog
|
|
30
30
|
span.service = service_name(host, request_options, client_config)
|
31
31
|
span.type = Tracing::Metadata::Ext::HTTP::TYPE_OUTBOUND
|
32
32
|
|
33
|
-
if
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
if Tracing::Distributed::PropagationPolicy.enabled?(
|
34
|
+
pin_config: client_config,
|
35
|
+
global_config: Datadog.configuration.tracing[:httpclient],
|
36
|
+
trace: trace
|
37
|
+
)
|
38
38
|
Contrib::HTTP.inject(trace, req.header)
|
39
39
|
end
|
40
40
|
|
@@ -123,12 +123,6 @@ module Datadog
|
|
123
123
|
Contrib::Analytics.enabled?(request_options[:analytics_enabled])
|
124
124
|
end
|
125
125
|
|
126
|
-
def should_skip_distributed_tracing?(client_config)
|
127
|
-
return !client_config[:distributed_tracing] if client_config && client_config.key?(:distributed_tracing)
|
128
|
-
|
129
|
-
!Datadog.configuration.tracing[:httpclient][:distributed_tracing]
|
130
|
-
end
|
131
|
-
|
132
126
|
def set_analytics_sample_rate(span, request_options)
|
133
127
|
return unless analytics_enabled?(request_options)
|
134
128
|
|
@@ -30,12 +30,14 @@ module Datadog
|
|
30
30
|
span.service = service_name(host, request_options, client_config)
|
31
31
|
span.type = Tracing::Metadata::Ext::HTTP::TYPE_OUTBOUND
|
32
32
|
|
33
|
-
if
|
34
|
-
|
33
|
+
if Tracing::Distributed::PropagationPolicy.enabled?(
|
34
|
+
pin_config: client_config,
|
35
|
+
global_config: Datadog.configuration.tracing[:httprb],
|
36
|
+
trace: trace
|
37
|
+
)
|
38
|
+
Contrib::HTTP.inject(trace, req)
|
35
39
|
end
|
36
40
|
|
37
|
-
Contrib::HTTP.inject(trace, req) if Tracing.enabled? && !should_skip_distributed_tracing?(client_config)
|
38
|
-
|
39
41
|
# Add additional request specific tags to the span.
|
40
42
|
annotate_span_with_request!(span, req, request_options)
|
41
43
|
rescue StandardError => e
|
@@ -135,12 +137,6 @@ module Datadog
|
|
135
137
|
Datadog.logger
|
136
138
|
end
|
137
139
|
|
138
|
-
def should_skip_distributed_tracing?(client_config)
|
139
|
-
return !client_config[:distributed_tracing] if client_config && client_config.key?(:distributed_tracing)
|
140
|
-
|
141
|
-
!Datadog.configuration.tracing[:httprb][:distributed_tracing]
|
142
|
-
end
|
143
|
-
|
144
140
|
def set_analytics_sample_rate(span, request_options)
|
145
141
|
return unless analytics_enabled?(request_options)
|
146
142
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../configuration/settings'
|
4
|
+
require_relative '../ext'
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module Tracing
|
8
|
+
module Contrib
|
9
|
+
module Karafka
|
10
|
+
module Configuration
|
11
|
+
# @public_api
|
12
|
+
class Settings < Contrib::Configuration::Settings
|
13
|
+
option :enabled do |o|
|
14
|
+
o.type :bool
|
15
|
+
o.env Ext::ENV_ENABLED
|
16
|
+
o.default true
|
17
|
+
end
|
18
|
+
|
19
|
+
option :service_name
|
20
|
+
|
21
|
+
option :distributed_tracing, default: false, type: :bool
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../distributed/fetcher'
|
4
|
+
require_relative '../../../distributed/propagation'
|
5
|
+
require_relative '../../../distributed/b3_multi'
|
6
|
+
require_relative '../../../distributed/b3_single'
|
7
|
+
require_relative '../../../distributed/datadog'
|
8
|
+
require_relative '../../../distributed/none'
|
9
|
+
require_relative '../../../distributed/trace_context'
|
10
|
+
require_relative '../../../configuration/ext'
|
11
|
+
|
12
|
+
module Datadog
|
13
|
+
module Tracing
|
14
|
+
module Contrib
|
15
|
+
module Karafka
|
16
|
+
module Distributed
|
17
|
+
# Extracts and injects propagation through Kafka message headers.
|
18
|
+
class Propagation < Tracing::Distributed::Propagation
|
19
|
+
def initialize(
|
20
|
+
propagation_style_inject:,
|
21
|
+
propagation_style_extract:,
|
22
|
+
propagation_extract_first:
|
23
|
+
)
|
24
|
+
super(
|
25
|
+
propagation_styles: {
|
26
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER =>
|
27
|
+
Tracing::Distributed::B3Multi.new(fetcher: Tracing::Distributed::Fetcher),
|
28
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER =>
|
29
|
+
Tracing::Distributed::B3Single.new(fetcher: Tracing::Distributed::Fetcher),
|
30
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG =>
|
31
|
+
Tracing::Distributed::Datadog.new(fetcher: Tracing::Distributed::Fetcher),
|
32
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT =>
|
33
|
+
Tracing::Distributed::TraceContext.new(fetcher: Tracing::Distributed::Fetcher),
|
34
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_NONE => Tracing::Distributed::None.new
|
35
|
+
},
|
36
|
+
propagation_style_inject: propagation_style_inject,
|
37
|
+
propagation_style_extract: propagation_style_extract,
|
38
|
+
propagation_extract_first: propagation_extract_first
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|