ddtrace 0.33.1 → 0.34.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/.circleci/config.yml +3 -0
- data/Appraisals +29 -5
- data/CHANGELOG.md +23 -1
- data/Rakefile +72 -11
- data/docker-compose.yml +20 -0
- data/docs/GettingStarted.md +63 -10
- data/lib/ddtrace.rb +4 -0
- data/lib/ddtrace/analytics.rb +7 -0
- data/lib/ddtrace/configuration/base.rb +2 -1
- data/lib/ddtrace/configuration/option.rb +9 -1
- data/lib/ddtrace/configuration/option_definition.rb +0 -4
- data/lib/ddtrace/configuration/settings.rb +78 -23
- data/lib/ddtrace/contrib/action_cable/events/perform_action.rb +3 -0
- data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +4 -0
- data/lib/ddtrace/contrib/action_view/events/render_partial.rb +3 -0
- data/lib/ddtrace/contrib/action_view/events/render_template.rb +3 -0
- data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +3 -0
- data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +6 -0
- data/lib/ddtrace/contrib/active_model_serializers/event.rb +3 -0
- data/lib/ddtrace/contrib/active_record/events/instantiation.rb +3 -0
- data/lib/ddtrace/contrib/analytics.rb +4 -0
- data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +39 -0
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +4 -0
- data/lib/ddtrace/contrib/ethon/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +22 -13
- data/lib/ddtrace/contrib/ethon/integration.rb +5 -0
- data/lib/ddtrace/contrib/excon/integration.rb +5 -0
- data/lib/ddtrace/contrib/excon/middleware.rb +12 -9
- data/lib/ddtrace/contrib/faraday/integration.rb +5 -0
- data/lib/ddtrace/contrib/faraday/middleware.rb +20 -32
- data/lib/ddtrace/contrib/faraday/patcher.rb +6 -1
- data/lib/ddtrace/contrib/faraday/rack_builder.rb +18 -0
- data/lib/ddtrace/contrib/grape/endpoint.rb +9 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +3 -0
- data/lib/ddtrace/contrib/http/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/http/instrumentation.rb +65 -21
- data/lib/ddtrace/contrib/http/integration.rb +5 -0
- data/lib/ddtrace/contrib/http_annotation_helper.rb +10 -0
- data/lib/ddtrace/contrib/presto/configuration/settings.rb +8 -6
- data/lib/ddtrace/contrib/presto/instrumentation.rb +8 -8
- data/lib/ddtrace/contrib/racecar/event.rb +4 -0
- data/lib/ddtrace/contrib/rack/middlewares.rb +4 -0
- data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -0
- data/lib/ddtrace/contrib/resque/resque_job.rb +4 -0
- data/lib/ddtrace/contrib/shoryuken/tracer.rb +4 -0
- data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +4 -0
- data/lib/ddtrace/contrib/sinatra/tracer.rb +3 -0
- data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +3 -0
- data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +14 -0
- data/lib/ddtrace/correlation.rb +12 -5
- data/lib/ddtrace/environment.rb +4 -0
- data/lib/ddtrace/event.rb +52 -0
- data/lib/ddtrace/ext/analytics.rb +1 -0
- data/lib/ddtrace/ext/correlation.rb +10 -0
- data/lib/ddtrace/ext/environment.rb +13 -0
- data/lib/ddtrace/metrics.rb +7 -0
- data/lib/ddtrace/opentelemetry/extensions.rb +13 -0
- data/lib/ddtrace/opentelemetry/span.rb +33 -0
- data/lib/ddtrace/span.rb +2 -1
- data/lib/ddtrace/tracer.rb +13 -3
- data/lib/ddtrace/version.rb +2 -2
- data/lib/ddtrace/worker.rb +20 -0
- data/lib/ddtrace/workers/async.rb +165 -0
- data/lib/ddtrace/workers/loop.rb +105 -0
- data/lib/ddtrace/workers/polling.rb +48 -0
- data/lib/ddtrace/workers/queue.rb +39 -0
- metadata +15 -2
@@ -2,6 +2,7 @@ require 'ddtrace/contrib/patcher'
|
|
2
2
|
require 'ddtrace/ext/app_types'
|
3
3
|
require 'ddtrace/contrib/faraday/ext'
|
4
4
|
require 'ddtrace/contrib/faraday/connection'
|
5
|
+
require 'ddtrace/contrib/faraday/rack_builder'
|
5
6
|
|
6
7
|
module Datadog
|
7
8
|
module Contrib
|
@@ -39,7 +40,11 @@ module Datadog
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def add_default_middleware!
|
42
|
-
::
|
43
|
+
if target_version >= Gem::Version.new('1.0.0')
|
44
|
+
::Faraday::Connection.send(:prepend, Connection)
|
45
|
+
else
|
46
|
+
::Faraday::RackBuilder.send(:prepend, RackBuilder)
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
def get_option(option)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Datadog
|
2
|
+
module Contrib
|
3
|
+
module Faraday
|
4
|
+
# Handles installation of our middleware if the user has *not*
|
5
|
+
# already explicitly configured it for this correction.
|
6
|
+
#
|
7
|
+
# RackBuilder class was introduced in faraday 0.9.0:
|
8
|
+
# https://github.com/lostisland/faraday/commit/77d7546d6d626b91086f427c56bc2cdd951353b3
|
9
|
+
module RackBuilder
|
10
|
+
def adapter(*args)
|
11
|
+
use(:ddtrace) unless @handlers.any? { |h| h.klass == Middleware }
|
12
|
+
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -85,6 +85,9 @@ module Datadog
|
|
85
85
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate)
|
86
86
|
end
|
87
87
|
|
88
|
+
# Measure service stats
|
89
|
+
Contrib::Analytics.set_measured(span)
|
90
|
+
|
88
91
|
# catch thrown exceptions
|
89
92
|
span.set_error(payload[:exception_object]) unless payload[:exception_object].nil?
|
90
93
|
|
@@ -126,6 +129,9 @@ module Datadog
|
|
126
129
|
|
127
130
|
# catch thrown exceptions
|
128
131
|
begin
|
132
|
+
# Measure service stats
|
133
|
+
Contrib::Analytics.set_measured(span)
|
134
|
+
|
129
135
|
span.set_error(payload[:exception_object]) unless payload[:exception_object].nil?
|
130
136
|
ensure
|
131
137
|
span.start_time = start
|
@@ -156,6 +162,9 @@ module Datadog
|
|
156
162
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate)
|
157
163
|
end
|
158
164
|
|
165
|
+
# Measure service stats
|
166
|
+
Contrib::Analytics.set_measured(span)
|
167
|
+
|
159
168
|
# catch thrown exceptions
|
160
169
|
span.set_error(payload[:exception_object]) unless payload[:exception_object].nil?
|
161
170
|
span.set_tag(Ext::TAG_FILTER_TYPE, type.to_s)
|
@@ -48,6 +48,9 @@ module Datadog
|
|
48
48
|
|
49
49
|
# Set analytics sample rate
|
50
50
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
51
|
+
|
52
|
+
# Measure service stats
|
53
|
+
Contrib::Analytics.set_measured(span)
|
51
54
|
rescue StandardError => e
|
52
55
|
Datadog::Logger.log.debug("GRPC client trace failed: #{e}")
|
53
56
|
end
|
@@ -5,6 +5,7 @@ require 'ddtrace/ext/http'
|
|
5
5
|
require 'ddtrace/ext/net'
|
6
6
|
require 'ddtrace/ext/distributed'
|
7
7
|
require 'ddtrace/contrib/analytics'
|
8
|
+
require 'ddtrace/contrib/http_annotation_helper'
|
8
9
|
|
9
10
|
module Datadog
|
10
11
|
module Contrib
|
@@ -28,8 +29,12 @@ module Datadog
|
|
28
29
|
|
29
30
|
# InstanceMethods - implementing instrumentation
|
30
31
|
module InstanceMethods
|
32
|
+
include Datadog::Contrib::HttpAnnotationHelper
|
33
|
+
|
31
34
|
def request(req, body = nil, &block) # :yield: +response+
|
32
|
-
|
35
|
+
host, = host_and_port(req)
|
36
|
+
request_options = datadog_configuration(host)
|
37
|
+
pin = datadog_pin(request_options)
|
33
38
|
return super(req, body, &block) unless pin && pin.tracer
|
34
39
|
|
35
40
|
if Datadog::Contrib::HTTP.should_skip_tracing?(req, @address, @port, pin.tracer)
|
@@ -38,7 +43,11 @@ module Datadog
|
|
38
43
|
|
39
44
|
pin.tracer.trace(Ext::SPAN_REQUEST, on_error: method(:annotate_span_with_error!)) do |span|
|
40
45
|
begin
|
41
|
-
|
46
|
+
# even though service_name might already be in request_options,
|
47
|
+
# we need to capture the name from the pin since it could be
|
48
|
+
# overridden
|
49
|
+
request_options[:service_name] = pin.service_name
|
50
|
+
span.service = service_name(host, request_options)
|
42
51
|
span.span_type = Datadog::Ext::HTTP::TYPE_OUTBOUND
|
43
52
|
span.resource = req.method
|
44
53
|
|
@@ -47,7 +56,7 @@ module Datadog
|
|
47
56
|
end
|
48
57
|
|
49
58
|
# Add additional request specific tags to the span.
|
50
|
-
annotate_span_with_request!(span, req)
|
59
|
+
annotate_span_with_request!(span, req, request_options)
|
51
60
|
rescue StandardError => e
|
52
61
|
Datadog::Logger.log.error("error preparing span for http request: #{e}")
|
53
62
|
ensure
|
@@ -66,20 +75,16 @@ module Datadog
|
|
66
75
|
end
|
67
76
|
end
|
68
77
|
|
69
|
-
def annotate_span_with_request!(span, request)
|
78
|
+
def annotate_span_with_request!(span, request, request_options)
|
70
79
|
span.set_tag(Datadog::Ext::HTTP::URL, request.path)
|
71
80
|
span.set_tag(Datadog::Ext::HTTP::METHOD, request.method)
|
72
81
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
else
|
77
|
-
span.set_tag(Datadog::Ext::NET::TARGET_HOST, @address)
|
78
|
-
span.set_tag(Datadog::Ext::NET::TARGET_PORT, @port.to_s)
|
79
|
-
end
|
82
|
+
host, port = host_and_port(request)
|
83
|
+
span.set_tag(Datadog::Ext::NET::TARGET_HOST, host)
|
84
|
+
span.set_tag(Datadog::Ext::NET::TARGET_PORT, port.to_s)
|
80
85
|
|
81
86
|
# Set analytics sample rate
|
82
|
-
|
87
|
+
set_analytics_sample_rate(span, request_options)
|
83
88
|
end
|
84
89
|
|
85
90
|
def annotate_span_with_response!(span, response)
|
@@ -97,27 +102,66 @@ module Datadog
|
|
97
102
|
span.set_error(error)
|
98
103
|
end
|
99
104
|
|
100
|
-
def
|
105
|
+
def set_analytics_sample_rate(span, request_options)
|
106
|
+
return unless analytics_enabled?(request_options)
|
107
|
+
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate(request_options))
|
108
|
+
end
|
109
|
+
|
110
|
+
def datadog_pin(config = Datadog.configuration[:http])
|
111
|
+
service = config[:service_name]
|
112
|
+
tracer = config[:tracer]
|
113
|
+
|
101
114
|
@datadog_pin ||= begin
|
102
|
-
service
|
103
|
-
|
115
|
+
Datadog::Pin.new(service, app: Ext::APP, app_type: Datadog::Ext::AppTypes::WEB, tracer: tracer)
|
116
|
+
end
|
104
117
|
|
118
|
+
# this shockingly poor code exists to solve the case where someone
|
119
|
+
# calls datadog_pin on this object before running a request, which
|
120
|
+
# would cause the :default config to be used. If a request is then
|
121
|
+
# run for a hostname that matches a different configuration, we
|
122
|
+
# would use the wrong configs since the pin is memoized.
|
123
|
+
# The solution is to detect if we are using the default config and
|
124
|
+
# apply the new config if necessary, while still allowing custom
|
125
|
+
# values to be supplied
|
126
|
+
if @datadog_pin.service_name == default_datadog_pin.service_name && @datadog_pin.service_name != service
|
127
|
+
@datadog_pin.service = service
|
128
|
+
end
|
129
|
+
if @datadog_pin.tracer == default_datadog_pin.tracer && @datadog_pin.tracer != tracer
|
130
|
+
@datadog_pin.tracer = tracer
|
131
|
+
end
|
132
|
+
|
133
|
+
@datadog_pin
|
134
|
+
end
|
135
|
+
|
136
|
+
def default_datadog_pin
|
137
|
+
config = Datadog.configuration[:http]
|
138
|
+
service = config[:service_name]
|
139
|
+
tracer = config[:tracer]
|
140
|
+
@default_datadog_pin ||= begin
|
105
141
|
Datadog::Pin.new(service, app: Ext::APP, app_type: Datadog::Ext::AppTypes::WEB, tracer: tracer)
|
106
142
|
end
|
107
143
|
end
|
108
144
|
|
109
145
|
private
|
110
146
|
|
111
|
-
def
|
112
|
-
|
147
|
+
def host_and_port(request)
|
148
|
+
if request.respond_to?(:uri) && request.uri
|
149
|
+
[request.uri.host, request.uri.port]
|
150
|
+
else
|
151
|
+
[@address, @port]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def datadog_configuration(host = :default)
|
156
|
+
Datadog.configuration[:http, host]
|
113
157
|
end
|
114
158
|
|
115
|
-
def analytics_enabled?
|
116
|
-
Contrib::Analytics.enabled?(
|
159
|
+
def analytics_enabled?(request_options)
|
160
|
+
Contrib::Analytics.enabled?(request_options[:analytics_enabled])
|
117
161
|
end
|
118
162
|
|
119
|
-
def analytics_sample_rate
|
120
|
-
|
163
|
+
def analytics_sample_rate(request_options)
|
164
|
+
request_options[:analytics_sample_rate]
|
121
165
|
end
|
122
166
|
end
|
123
167
|
end
|
@@ -2,6 +2,7 @@ require 'ddtrace/version'
|
|
2
2
|
|
3
3
|
require 'ddtrace/contrib/integration'
|
4
4
|
require 'ddtrace/contrib/http/configuration/settings'
|
5
|
+
require 'ddtrace/contrib/configuration/resolvers/pattern_resolver'
|
5
6
|
require 'ddtrace/contrib/http/patcher'
|
6
7
|
require 'ddtrace/contrib/http/circuit_breaker'
|
7
8
|
|
@@ -34,6 +35,10 @@ module Datadog
|
|
34
35
|
def patcher
|
35
36
|
Patcher
|
36
37
|
end
|
38
|
+
|
39
|
+
def resolver
|
40
|
+
@resolver ||= Contrib::Configuration::Resolvers::PatternResolver.new
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Datadog
|
2
|
+
module Contrib
|
3
|
+
# Contains methods helpful for tracing/annotating HTTP request libraries
|
4
|
+
module HttpAnnotationHelper
|
5
|
+
def service_name(hostname, configuration_options)
|
6
|
+
configuration_options[:split_by_domain] ? hostname : configuration_options[:service_name]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -7,13 +7,15 @@ module Datadog
|
|
7
7
|
module Configuration
|
8
8
|
# Custom settings for the Presto integration
|
9
9
|
class Settings < Contrib::Configuration::Settings
|
10
|
-
option
|
11
|
-
|
12
|
-
|
10
|
+
option :analytics_enabled do |o|
|
11
|
+
o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) }
|
12
|
+
o.lazy
|
13
|
+
end
|
13
14
|
|
14
|
-
option
|
15
|
-
|
16
|
-
|
15
|
+
option :analytics_sample_rate do |o|
|
16
|
+
o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
|
17
|
+
o.lazy
|
18
|
+
end
|
17
19
|
|
18
20
|
option :service_name, default: Ext::SERVICE_NAME
|
19
21
|
end
|
@@ -25,9 +25,9 @@ module Datadog
|
|
25
25
|
span.set_tag(Ext::TAG_QUERY_ASYNC, false)
|
26
26
|
rescue StandardError => e
|
27
27
|
Datadog::Logger.log.debug("error preparing span for presto: #{e}")
|
28
|
-
ensure
|
29
|
-
super(query)
|
30
28
|
end
|
29
|
+
|
30
|
+
super(query)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -40,9 +40,9 @@ module Datadog
|
|
40
40
|
span.set_tag(Ext::TAG_QUERY_ASYNC, !blk.nil?)
|
41
41
|
rescue StandardError => e
|
42
42
|
Datadog::Logger.log.debug("error preparing span for presto: #{e}")
|
43
|
-
ensure
|
44
|
-
super(query, &blk)
|
45
43
|
end
|
44
|
+
|
45
|
+
super(query, &blk)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -56,9 +56,9 @@ module Datadog
|
|
56
56
|
span.set_tag(Ext::TAG_QUERY_ID, query_id)
|
57
57
|
rescue StandardError => e
|
58
58
|
Datadog::Logger.log.debug("error preparing span for presto: #{e}")
|
59
|
-
ensure
|
60
|
-
super(query_id)
|
61
59
|
end
|
60
|
+
|
61
|
+
super(query_id)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -91,8 +91,8 @@ module Datadog
|
|
91
91
|
set_nilable_tag!(span, :model_version, Ext::TAG_MODEL_VERSION)
|
92
92
|
|
93
93
|
# Set analytics sample rate
|
94
|
-
if Contrib::Analytics.enabled?(
|
95
|
-
Contrib::Analytics.set_sample_rate(span,
|
94
|
+
if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
|
95
|
+
Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -41,6 +41,10 @@ module Datadog
|
|
41
41
|
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
42
42
|
Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
|
43
43
|
end
|
44
|
+
|
45
|
+
# Measure service stats
|
46
|
+
Contrib::Analytics.set_measured(span)
|
47
|
+
|
44
48
|
span.set_tag(Ext::TAG_TOPIC, payload[:topic])
|
45
49
|
span.set_tag(Ext::TAG_CONSUMER, payload[:consumer_class])
|
46
50
|
span.set_tag(Ext::TAG_PARTITION, payload[:partition])
|
@@ -126,6 +126,7 @@ module Datadog
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# rubocop:disable Metrics/AbcSize
|
129
|
+
# rubocop:disable Metrics/MethodLength
|
129
130
|
def set_request_tags!(request_span, env, status, headers, response, original_env)
|
130
131
|
# http://www.rubydoc.info/github/rack/rack/file/SPEC
|
131
132
|
# The source of truth in Rack is the PATH_INFO key that holds the
|
@@ -152,6 +153,9 @@ module Datadog
|
|
152
153
|
Contrib::Analytics.set_sample_rate(request_span, configuration[:analytics_sample_rate])
|
153
154
|
end
|
154
155
|
|
156
|
+
# Measure service stats
|
157
|
+
Contrib::Analytics.set_measured(request_span)
|
158
|
+
|
155
159
|
if request_span.get_tag(Datadog::Ext::HTTP::METHOD).nil?
|
156
160
|
request_span.set_tag(Datadog::Ext::HTTP::METHOD, env['REQUEST_METHOD'])
|
157
161
|
end
|
@@ -44,6 +44,10 @@ module Datadog
|
|
44
44
|
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
45
45
|
Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
|
46
46
|
end
|
47
|
+
|
48
|
+
# Measure service stats
|
49
|
+
Contrib::Analytics.set_measured(span)
|
50
|
+
|
47
51
|
span.set_tag(Ext::TAG_TASK_ARG_NAMES, arg_names)
|
48
52
|
span.set_tag(Ext::TAG_INVOKE_ARGS, quantize_args(args)) unless args.nil?
|
49
53
|
rescue StandardError => e
|
@@ -19,6 +19,10 @@ module Datadog
|
|
19
19
|
if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
|
20
20
|
Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
|
21
21
|
end
|
22
|
+
|
23
|
+
# Measure service stats
|
24
|
+
Contrib::Analytics.set_measured(span)
|
25
|
+
|
22
26
|
yield
|
23
27
|
end
|
24
28
|
end
|
@@ -16,6 +16,10 @@ module Datadog
|
|
16
16
|
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
17
17
|
Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
|
18
18
|
end
|
19
|
+
|
20
|
+
# Measure service stats
|
21
|
+
Contrib::Analytics.set_measured(span)
|
22
|
+
|
19
23
|
span.resource = resource(worker_instance, body)
|
20
24
|
span.set_tag(Ext::TAG_JOB_ID, sqs_msg.message_id)
|
21
25
|
span.set_tag(Ext::TAG_JOB_QUEUE, queue)
|
@@ -25,6 +25,10 @@ module Datadog
|
|
25
25
|
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
26
26
|
Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
|
27
27
|
end
|
28
|
+
|
29
|
+
# Measure service stats
|
30
|
+
Contrib::Analytics.set_measured(span)
|
31
|
+
|
28
32
|
span.set_tag(Ext::TAG_JOB_ID, job['jid'])
|
29
33
|
span.set_tag(Ext::TAG_JOB_RETRY, job['retry'])
|
30
34
|
span.set_tag(Ext::TAG_JOB_QUEUE, job['queue'])
|
@@ -41,6 +41,9 @@ module Datadog
|
|
41
41
|
# Set analytics sample rate
|
42
42
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
43
43
|
|
44
|
+
# Measure service stats
|
45
|
+
Contrib::Analytics.set_measured(span)
|
46
|
+
|
44
47
|
[status, headers, response_body]
|
45
48
|
end
|
46
49
|
end
|
@@ -11,6 +11,7 @@ module Datadog
|
|
11
11
|
|
12
12
|
# rubocop:disable Metrics/MethodLength
|
13
13
|
def patch!
|
14
|
+
# rubocop:disable Metrics/BlockLength
|
14
15
|
::SuckerPunch::Job::ClassMethods.class_eval do
|
15
16
|
alias_method :__run_perform_without_datadog, :__run_perform
|
16
17
|
def __run_perform(*args)
|
@@ -19,10 +20,15 @@ module Datadog
|
|
19
20
|
|
20
21
|
__with_instrumentation(Ext::SPAN_PERFORM) do |span|
|
21
22
|
span.resource = "PROCESS #{self}"
|
23
|
+
|
22
24
|
# Set analytics sample rate
|
23
25
|
if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
|
24
26
|
Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
|
25
27
|
end
|
28
|
+
|
29
|
+
# Measure service stats
|
30
|
+
Contrib::Analytics.set_measured(span)
|
31
|
+
|
26
32
|
__run_perform_without_datadog(*args)
|
27
33
|
end
|
28
34
|
rescue => e
|
@@ -33,6 +39,10 @@ module Datadog
|
|
33
39
|
def perform_async(*args)
|
34
40
|
__with_instrumentation(Ext::SPAN_PERFORM_ASYNC) do |span|
|
35
41
|
span.resource = "ENQUEUE #{self}"
|
42
|
+
|
43
|
+
# Measure service stats
|
44
|
+
Contrib::Analytics.set_measured(span)
|
45
|
+
|
36
46
|
__perform_async(*args)
|
37
47
|
end
|
38
48
|
end
|
@@ -42,6 +52,10 @@ module Datadog
|
|
42
52
|
__with_instrumentation(Ext::SPAN_PERFORM_IN) do |span|
|
43
53
|
span.resource = "ENQUEUE #{self}"
|
44
54
|
span.set_tag(Ext::TAG_PERFORM_IN, interval)
|
55
|
+
|
56
|
+
# Measure service stats
|
57
|
+
Contrib::Analytics.set_measured(span)
|
58
|
+
|
45
59
|
__perform_in(interval, *args)
|
46
60
|
end
|
47
61
|
end
|