ddtrace 1.11.0.beta1 → 1.11.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 +56 -1
- data/README.md +0 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +34 -7
- data/lib/datadog/appsec/component.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +2 -3
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +62 -11
- data/lib/datadog/core/configuration/settings.rb +5 -6
- data/lib/datadog/core/environment/identity.rb +56 -0
- data/lib/datadog/core/remote/client.rb +98 -19
- data/lib/datadog/core/remote/component.rb +29 -21
- data/lib/datadog/core/remote/configuration/content.rb +2 -0
- data/lib/datadog/core/remote/configuration/repository.rb +15 -1
- data/lib/datadog/core/remote/configuration/target.rb +5 -3
- data/lib/datadog/core/remote/negotiation.rb +57 -0
- data/lib/datadog/core/transport/http/negotiation.rb +1 -1
- data/lib/datadog/core/workers/async.rb +6 -2
- data/lib/datadog/core/workers/interval_loop.rb +5 -1
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +4 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +4 -2
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +2 -1
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +4 -1
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +4 -1
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +5 -3
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +4 -2
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -2
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -2
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +5 -2
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -2
- data/lib/datadog/tracing/contrib/sidekiq/integration.rb +8 -0
- data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +14 -2
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +9 -4
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/stop.rb +34 -0
- data/lib/ddtrace/version.rb +4 -2
- metadata +6 -3
@@ -5,6 +5,7 @@ require_relative 'client/capabilities'
|
|
5
5
|
require_relative 'client'
|
6
6
|
require_relative '../transport/http'
|
7
7
|
require_relative '../remote'
|
8
|
+
require_relative 'negotiation'
|
8
9
|
|
9
10
|
module Datadog
|
10
11
|
module Core
|
@@ -16,27 +17,43 @@ module Datadog
|
|
16
17
|
|
17
18
|
attr_reader :client
|
18
19
|
|
19
|
-
def initialize(settings, agent_settings)
|
20
|
+
def initialize(settings, capabilities, agent_settings)
|
20
21
|
transport_options = {}
|
21
22
|
transport_options[:agent_settings] = agent_settings if agent_settings
|
22
23
|
|
24
|
+
negotiation = Negotiation.new(settings, agent_settings)
|
23
25
|
transport_v7 = Datadog::Core::Transport::HTTP.v7(**transport_options.dup)
|
24
26
|
|
25
|
-
capabilities = Client::Capabilities.new(settings)
|
26
|
-
|
27
27
|
@barrier = Barrier.new(BARRIER_TIMEOUT)
|
28
28
|
|
29
29
|
@client = Client.new(transport_v7, capabilities)
|
30
|
+
healthy = false
|
31
|
+
Datadog.logger.debug { "new remote configuration client: #{@client.id}" }
|
32
|
+
|
30
33
|
@worker = Worker.new(interval: settings.remote.poll_interval_seconds) do
|
34
|
+
unless healthy || negotiation.endpoint?('/v0.7/config')
|
35
|
+
@barrier.lift
|
36
|
+
|
37
|
+
next
|
38
|
+
end
|
39
|
+
|
31
40
|
begin
|
32
41
|
@client.sync
|
42
|
+
healthy ||= true
|
43
|
+
rescue Client::SyncError => e
|
44
|
+
Datadog.logger.error do
|
45
|
+
"remote worker client sync error: #{e.message} location: #{Array(e.backtrace).first}. skipping sync"
|
46
|
+
end
|
33
47
|
rescue StandardError => e
|
34
48
|
Datadog.logger.error do
|
35
|
-
"remote worker error: #{e.class.name} #{e.message} location: #{Array(e.backtrace).first}"
|
49
|
+
"remote worker error: #{e.class.name} #{e.message} location: #{Array(e.backtrace).first}. "\
|
50
|
+
'reseting client state'
|
36
51
|
end
|
37
52
|
|
38
53
|
# client state is unknown, state might be corrupted
|
39
54
|
@client = Client.new(transport_v7, capabilities)
|
55
|
+
healthy = false
|
56
|
+
Datadog.logger.debug { "new remote configuration client: #{@client.id}" }
|
40
57
|
|
41
58
|
# TODO: bail out if too many errors?
|
42
59
|
end
|
@@ -116,32 +133,23 @@ module Datadog
|
|
116
133
|
def build(settings, agent_settings)
|
117
134
|
return unless settings.remote.enabled
|
118
135
|
|
119
|
-
|
120
|
-
transport_options[:agent_settings] = agent_settings if agent_settings
|
136
|
+
capabilities = Client::Capabilities.new(settings)
|
121
137
|
|
122
|
-
|
138
|
+
return if capabilities.products.empty?
|
123
139
|
|
124
|
-
|
125
|
-
if res.ok?
|
126
|
-
if res.endpoints.include?('/v0.7/config')
|
127
|
-
Datadog.logger.debug { 'agent reachable and reports remote configuration endpoint' }
|
128
|
-
else
|
129
|
-
Datadog.logger.error do
|
130
|
-
'agent reachable but does not report remote configuration endpoint: ' \
|
131
|
-
'disabling remote configuration for this process.'
|
132
|
-
end
|
140
|
+
negotiation = Negotiation.new(settings, agent_settings)
|
133
141
|
|
134
|
-
|
135
|
-
end
|
136
|
-
else
|
142
|
+
unless negotiation.endpoint?('/v0.7/config')
|
137
143
|
Datadog.logger.error do
|
138
|
-
'
|
144
|
+
'endpoint unavailable: disabling remote configuration for this process.'
|
139
145
|
end
|
140
146
|
|
141
147
|
return
|
142
148
|
end
|
143
149
|
|
144
|
-
|
150
|
+
Datadog.logger.debug { 'agent reachable and reports remote configuration endpoint' }
|
151
|
+
|
152
|
+
new(settings, capabilities, agent_settings)
|
145
153
|
end
|
146
154
|
end
|
147
155
|
end
|
@@ -78,7 +78,7 @@ module Datadog
|
|
78
78
|
@repository = repository
|
79
79
|
@root_version = repository.root_version
|
80
80
|
@targets_version = repository.targets_version
|
81
|
-
@config_states =
|
81
|
+
@config_states = contents_to_config_states(repository.contents)
|
82
82
|
@has_error = false
|
83
83
|
@error = ''
|
84
84
|
@opaque_backend_state = repository.opaque_backend_state
|
@@ -87,6 +87,18 @@ module Datadog
|
|
87
87
|
|
88
88
|
private
|
89
89
|
|
90
|
+
def contents_to_config_states(contents)
|
91
|
+
return [] if contents.empty?
|
92
|
+
|
93
|
+
contents.map do |content|
|
94
|
+
{
|
95
|
+
id: content.path.config_id,
|
96
|
+
version: content.version,
|
97
|
+
product: content.path.product
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
90
102
|
def contents_to_cached_target_files(contents)
|
91
103
|
return [] if contents.empty?
|
92
104
|
|
@@ -164,6 +176,7 @@ module Datadog
|
|
164
176
|
def apply(repository)
|
165
177
|
return unless repository[@path].nil?
|
166
178
|
|
179
|
+
@content.version = @target.version
|
167
180
|
repository.contents << @content
|
168
181
|
|
169
182
|
@path
|
@@ -184,6 +197,7 @@ module Datadog
|
|
184
197
|
def apply(repository)
|
185
198
|
return if repository[@path].nil?
|
186
199
|
|
200
|
+
@content.version = @target.version
|
187
201
|
repository.contents[@path] = @content
|
188
202
|
|
189
203
|
@path
|
@@ -48,16 +48,18 @@ module Datadog
|
|
48
48
|
def parse(hash)
|
49
49
|
length = Integer(hash['length'])
|
50
50
|
digests = Configuration::DigestList.parse(hash['hashes'])
|
51
|
+
version = Integer(hash['custom']['v'])
|
51
52
|
|
52
|
-
new(digests: digests, length: length)
|
53
|
+
new(digests: digests, length: length, version: version)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
attr_reader :length, :digests
|
57
|
+
attr_reader :length, :digests, :version
|
57
58
|
|
58
|
-
def initialize(digests:, length:)
|
59
|
+
def initialize(digests:, length:, version:)
|
59
60
|
@digests = digests
|
60
61
|
@length = length
|
62
|
+
@version = version
|
61
63
|
end
|
62
64
|
|
63
65
|
private_class_method :new
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../transport/http'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Core
|
7
|
+
module Remote
|
8
|
+
# Endpoint negotiation
|
9
|
+
class Negotiation
|
10
|
+
def initialize(_settings, agent_settings)
|
11
|
+
transport_options = {}
|
12
|
+
transport_options[:agent_settings] = agent_settings if agent_settings
|
13
|
+
|
14
|
+
@transport_root = Datadog::Core::Transport::HTTP.root(**transport_options.dup)
|
15
|
+
end
|
16
|
+
|
17
|
+
def endpoint?(path)
|
18
|
+
res = @transport_root.send_info
|
19
|
+
|
20
|
+
if res.internal_error? && network_error?(res.error)
|
21
|
+
Datadog.logger.error { "agent unreachable: cannot negotiate #{path}" }
|
22
|
+
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
|
26
|
+
if res.not_found?
|
27
|
+
Datadog.logger.error { "agent reachable but has no /info endpoint: cannot negotiate #{path}" }
|
28
|
+
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
unless res.ok?
|
33
|
+
Datadog.logger.error { "agent reachable but unexpected response: cannot negotiate #{path}" }
|
34
|
+
|
35
|
+
return false
|
36
|
+
end
|
37
|
+
|
38
|
+
unless res.endpoints.include?(path)
|
39
|
+
Datadog.logger.error { "agent reachable but does not report #{path}" }
|
40
|
+
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
|
44
|
+
Datadog.logger.debug { "agent reachable and reports #{path}" }
|
45
|
+
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def network_error?(error)
|
52
|
+
error.is_a?(Errno::ECONNREFUSED)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -122,7 +122,7 @@ module Datadog
|
|
122
122
|
http_response = super(env, &block)
|
123
123
|
|
124
124
|
# Process the response
|
125
|
-
body = JSON.parse(http_response.payload, symbolize_names: true)
|
125
|
+
body = JSON.parse(http_response.payload, symbolize_names: true) if http_response.ok?
|
126
126
|
|
127
127
|
# TODO: there should be more processing here to ensure a proper response_options
|
128
128
|
response_options = body.is_a?(Hash) ? body : {}
|
@@ -11,6 +11,10 @@ module Datadog
|
|
11
11
|
FORK_POLICY_RESTART = :restart
|
12
12
|
SHUTDOWN_TIMEOUT = 1
|
13
13
|
|
14
|
+
# This single shared mutex is used to avoid concurrency issues during the
|
15
|
+
# initialization of per-instance lazy-initialized mutexes.
|
16
|
+
MUTEX_INIT = Mutex.new
|
17
|
+
|
14
18
|
def self.included(base)
|
15
19
|
base.prepend(PrependedMethods)
|
16
20
|
end
|
@@ -86,7 +90,7 @@ module Datadog
|
|
86
90
|
:result
|
87
91
|
|
88
92
|
def mutex
|
89
|
-
@mutex ||= Mutex.new
|
93
|
+
@mutex || MUTEX_INIT.synchronize { @mutex ||= Mutex.new }
|
90
94
|
end
|
91
95
|
|
92
96
|
def after_fork
|
@@ -99,7 +103,7 @@ module Datadog
|
|
99
103
|
:pid
|
100
104
|
|
101
105
|
def mutex_after_fork
|
102
|
-
@mutex_after_fork ||= Mutex.new
|
106
|
+
@mutex_after_fork || MUTEX_INIT.synchronize { @mutex_after_fork ||= Mutex.new }
|
103
107
|
end
|
104
108
|
|
105
109
|
def worker
|
@@ -10,6 +10,10 @@ module Datadog
|
|
10
10
|
BACK_OFF_MAX = 5
|
11
11
|
BASE_INTERVAL = 1
|
12
12
|
|
13
|
+
# This single shared mutex is used to avoid concurrency issues during the
|
14
|
+
# initialization of per-instance lazy-initialized mutexes.
|
15
|
+
MUTEX_INIT = Mutex.new
|
16
|
+
|
13
17
|
def self.included(base)
|
14
18
|
base.prepend(PrependedMethods)
|
15
19
|
end
|
@@ -82,7 +86,7 @@ module Datadog
|
|
82
86
|
:loop_base_interval
|
83
87
|
|
84
88
|
def mutex
|
85
|
-
@mutex ||= Mutex.new
|
89
|
+
@mutex || MUTEX_INIT.synchronize { @mutex ||= Mutex.new }
|
86
90
|
end
|
87
91
|
|
88
92
|
private
|
@@ -46,7 +46,10 @@ module Datadog
|
|
46
46
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_SQL)
|
47
47
|
|
48
48
|
# Tag as an external peer service
|
49
|
-
|
49
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
50
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
51
|
+
end
|
52
|
+
|
50
53
|
# TODO: Populate hostname for JDBC connections
|
51
54
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, config[:host]) if config[:host]
|
52
55
|
|
@@ -42,8 +42,10 @@ module Datadog
|
|
42
42
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
43
43
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_CACHE)
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
46
|
+
# Tag as an external peer service
|
47
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, service)
|
48
|
+
end
|
47
49
|
|
48
50
|
tracing_context[:dd_cache_span] = span
|
49
51
|
rescue StandardError => e
|
@@ -42,9 +42,10 @@ module Datadog
|
|
42
42
|
# Tag as an external peer service
|
43
43
|
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
44
44
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
45
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, context.safely(:host))
|
46
45
|
end
|
47
46
|
|
47
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, context.safely(:host))
|
48
|
+
|
48
49
|
# Set analytics sample rate
|
49
50
|
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
50
51
|
Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
|
@@ -27,7 +27,12 @@ module Datadog
|
|
27
27
|
end
|
28
28
|
|
29
29
|
option :service_name do |o|
|
30
|
-
o.default
|
30
|
+
o.default do
|
31
|
+
Contrib::SpanAttributeSchema.fetch_service_name(
|
32
|
+
Ext::ENV_SERVICE_NAME,
|
33
|
+
Ext::DEFAULT_PEER_SERVICE_NAME
|
34
|
+
)
|
35
|
+
end
|
31
36
|
o.lazy
|
32
37
|
end
|
33
38
|
end
|
@@ -28,7 +28,10 @@ module Datadog
|
|
28
28
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_COMMAND)
|
29
29
|
|
30
30
|
# Tag as an external peer service
|
31
|
-
|
31
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
32
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
33
|
+
end
|
34
|
+
|
32
35
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, hostname)
|
33
36
|
|
34
37
|
# Set analytics sample rate
|
@@ -29,7 +29,12 @@ module Datadog
|
|
29
29
|
option :quantize, default: {}
|
30
30
|
|
31
31
|
option :service_name do |o|
|
32
|
-
o.default
|
32
|
+
o.default do
|
33
|
+
Contrib::SpanAttributeSchema.fetch_service_name(
|
34
|
+
Ext::ENV_SERVICE_NAME,
|
35
|
+
Ext::DEFAULT_PEER_SERVICE_NAME
|
36
|
+
)
|
37
|
+
end
|
33
38
|
o.lazy
|
34
39
|
end
|
35
40
|
end
|
@@ -90,7 +90,10 @@ module Datadog
|
|
90
90
|
body = JSON.generate(body) if body && !body.is_a?(String)
|
91
91
|
|
92
92
|
# Tag as an external peer service
|
93
|
-
|
93
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
94
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
95
|
+
end
|
96
|
+
|
94
97
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, host) if host
|
95
98
|
|
96
99
|
# Set analytics sample rate
|
@@ -31,7 +31,12 @@ module Datadog
|
|
31
31
|
option :split_by_domain, default: false
|
32
32
|
|
33
33
|
option :service_name do |o|
|
34
|
-
o.default
|
34
|
+
o.default do
|
35
|
+
Contrib::SpanAttributeSchema.fetch_service_name(
|
36
|
+
Ext::ENV_SERVICE_NAME,
|
37
|
+
Ext::DEFAULT_PEER_SERVICE_NAME
|
38
|
+
)
|
39
|
+
end
|
35
40
|
o.lazy
|
36
41
|
end
|
37
42
|
end
|
@@ -121,8 +121,11 @@ module Datadog
|
|
121
121
|
method = Ext::NOT_APPLICABLE_METHOD
|
122
122
|
method = @datadog_method.to_s if instance_variable_defined?(:@datadog_method) && !@datadog_method.nil?
|
123
123
|
span.resource = method
|
124
|
-
|
125
|
-
|
124
|
+
|
125
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
126
|
+
# Tag as an external peer service
|
127
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
128
|
+
end
|
126
129
|
# Set analytics sample rate
|
127
130
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
128
131
|
|
@@ -138,7 +141,6 @@ module Datadog
|
|
138
141
|
span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_METHOD, method)
|
139
142
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, uri.host)
|
140
143
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, uri.port)
|
141
|
-
|
142
144
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, uri.host)
|
143
145
|
end
|
144
146
|
|
@@ -69,8 +69,10 @@ module Datadog
|
|
69
69
|
|
70
70
|
@datadog_multi_span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
73
|
+
# Tag as an external peer service
|
74
|
+
@datadog_multi_span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, @datadog_multi_span.service)
|
75
|
+
end
|
74
76
|
|
75
77
|
# Set analytics sample rate
|
76
78
|
Contrib::Analytics.set_sample_rate(@datadog_multi_span, analytics_sample_rate) if analytics_enabled?
|
@@ -31,7 +31,12 @@ module Datadog
|
|
31
31
|
option :split_by_domain, default: false
|
32
32
|
|
33
33
|
option :service_name do |o|
|
34
|
-
o.default
|
34
|
+
o.default do
|
35
|
+
Contrib::SpanAttributeSchema.fetch_service_name(
|
36
|
+
Ext::ENV_SERVICE_NAME,
|
37
|
+
Ext::DEFAULT_PEER_SERVICE_NAME
|
38
|
+
)
|
39
|
+
end
|
35
40
|
o.lazy
|
36
41
|
end
|
37
42
|
end
|
@@ -119,8 +119,11 @@ module Datadog
|
|
119
119
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
120
120
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
|
121
121
|
|
122
|
-
|
123
|
-
|
122
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
123
|
+
# Tag as an external peer service
|
124
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
125
|
+
end
|
126
|
+
|
124
127
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, datum[:host])
|
125
128
|
|
126
129
|
# Set analytics sample rate
|
@@ -35,7 +35,12 @@ module Datadog
|
|
35
35
|
option :split_by_domain, default: false
|
36
36
|
|
37
37
|
option :service_name do |o|
|
38
|
-
o.default
|
38
|
+
o.default do
|
39
|
+
Contrib::SpanAttributeSchema.fetch_service_name(
|
40
|
+
Ext::ENV_SERVICE_NAME,
|
41
|
+
Ext::DEFAULT_PEER_SERVICE_NAME
|
42
|
+
)
|
43
|
+
end
|
39
44
|
o.lazy
|
40
45
|
end
|
41
46
|
end
|
@@ -45,8 +45,11 @@ module Datadog
|
|
45
45
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
46
46
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
49
|
+
# Tag as an external peer service
|
50
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
51
|
+
end
|
52
|
+
|
50
53
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, env[:url].host)
|
51
54
|
|
52
55
|
# Set analytics sample rate
|
@@ -30,7 +30,12 @@ module Datadog
|
|
30
30
|
option :distributed_tracing, default: true
|
31
31
|
|
32
32
|
option :service_name do |o|
|
33
|
-
o.default
|
33
|
+
o.default do
|
34
|
+
Contrib::SpanAttributeSchema.fetch_service_name(
|
35
|
+
Ext::ENV_SERVICE_NAME,
|
36
|
+
Ext::DEFAULT_PEER_SERVICE_NAME
|
37
|
+
)
|
38
|
+
end
|
34
39
|
o.lazy
|
35
40
|
end
|
36
41
|
|
@@ -43,8 +43,11 @@ module Datadog
|
|
43
43
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
44
44
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_CLIENT)
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
47
|
+
# Tag as an external peer service
|
48
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
49
|
+
end
|
50
|
+
|
48
51
|
host, _port = find_host_port(call)
|
49
52
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, host) if host
|
50
53
|
|
@@ -29,7 +29,12 @@ module Datadog
|
|
29
29
|
option :distributed_tracing, default: true
|
30
30
|
|
31
31
|
option :service_name do |o|
|
32
|
-
o.default
|
32
|
+
o.default do
|
33
|
+
Contrib::SpanAttributeSchema.fetch_service_name(
|
34
|
+
Ext::ENV_SERVICE_NAME,
|
35
|
+
Ext::DEFAULT_PEER_SERVICE_NAME
|
36
|
+
)
|
37
|
+
end
|
33
38
|
o.lazy
|
34
39
|
end
|
35
40
|
|
@@ -80,8 +80,11 @@ module Datadog
|
|
80
80
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, host)
|
81
81
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, port.to_s)
|
82
82
|
|
83
|
-
|
84
|
-
|
83
|
+
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
84
|
+
# Tag as an external peer service
|
85
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
86
|
+
end
|
87
|
+
|
85
88
|
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, host)
|
86
89
|
|
87
90
|
# Set analytics sample rate
|
@@ -12,6 +12,7 @@ module Datadog
|
|
12
12
|
|
13
13
|
MINIMUM_VERSION = Gem::Version.new('3.5.4')
|
14
14
|
MINIMUM_SERVER_INTERNAL_TRACING_VERSION = Gem::Version.new('5.2.4')
|
15
|
+
MINIMUM_CAPSULE_VERSION = Gem::Version.new('7.0.0')
|
15
16
|
|
16
17
|
# @public_api Changing the integration name or integration options can cause breaking changes
|
17
18
|
register_as :sidekiq
|
@@ -37,6 +38,13 @@ module Datadog
|
|
37
38
|
version >= MINIMUM_SERVER_INTERNAL_TRACING_VERSION
|
38
39
|
end
|
39
40
|
|
41
|
+
# Capsules are a new way of configuring Sidekiq that was introduced in version 7
|
42
|
+
# that change the way some of the configuration data is exposed. Certain patches
|
43
|
+
# are applied differently for versions of Sidekiq that support capsules.
|
44
|
+
def self.supports_capsules?
|
45
|
+
version >= MINIMUM_CAPSULE_VERSION
|
46
|
+
end
|
47
|
+
|
40
48
|
def new_configuration
|
41
49
|
Configuration::Settings.new
|
42
50
|
end
|
@@ -49,9 +49,17 @@ module Datadog
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def patch_server_heartbeat
|
52
|
+
require_relative 'server_internal_tracer/stop'
|
52
53
|
require_relative 'server_internal_tracer/heartbeat'
|
53
54
|
|
54
|
-
::Sidekiq::Launcher.prepend(ServerInternalTracer::
|
55
|
+
::Sidekiq::Launcher.prepend(ServerInternalTracer::Stop)
|
56
|
+
|
57
|
+
# Sidekiq 7 changed method `heartbeat` to `beat`
|
58
|
+
if ::Sidekiq::Launcher.private_method_defined? :heartbeat
|
59
|
+
::Sidekiq::Launcher.prepend(ServerInternalTracer::Heartbeat)
|
60
|
+
end
|
61
|
+
|
62
|
+
::Sidekiq::Launcher.prepend(ServerInternalTracer::Beat) if ::Sidekiq::Launcher.private_method_defined? :beat
|
55
63
|
end
|
56
64
|
|
57
65
|
def patch_server_job_fetch
|
@@ -69,7 +77,11 @@ module Datadog
|
|
69
77
|
def patch_redis_info
|
70
78
|
require_relative 'server_internal_tracer/redis_info'
|
71
79
|
|
72
|
-
|
80
|
+
if Integration.supports_capsules?
|
81
|
+
::Sidekiq::Config.prepend(ServerInternalTracer::RedisInfo)
|
82
|
+
else
|
83
|
+
::Sidekiq.singleton_class.prepend(ServerInternalTracer::RedisInfo)
|
84
|
+
end
|
73
85
|
end
|
74
86
|
end
|
75
87
|
end
|