ddtrace 0.9.2 → 0.10.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/.gitignore +2 -3
- data/Appraisals +1 -0
- data/ddtrace.gemspec +3 -0
- data/docs/GettingStarted.md +31 -8
- data/gemfiles/rails32_postgres_redis.gemfile +1 -0
- data/lib/ddtrace.rb +20 -34
- data/lib/ddtrace/buffer.rb +1 -7
- data/lib/ddtrace/configurable.rb +77 -0
- data/lib/ddtrace/configuration.rb +35 -0
- data/lib/ddtrace/configuration/proxy.rb +29 -0
- data/lib/ddtrace/configuration/resolver.rb +24 -0
- data/lib/ddtrace/context.rb +55 -7
- data/lib/ddtrace/contrib/active_record/patcher.rb +4 -1
- data/lib/ddtrace/contrib/aws/patcher.rb +3 -0
- data/lib/ddtrace/contrib/base.rb +14 -0
- data/lib/ddtrace/contrib/dalli/patcher.rb +3 -0
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +3 -0
- data/lib/ddtrace/contrib/faraday/middleware.rb +5 -6
- data/lib/ddtrace/contrib/faraday/patcher.rb +3 -0
- data/lib/ddtrace/contrib/grape/patcher.rb +3 -0
- data/lib/ddtrace/contrib/http/patcher.rb +22 -7
- data/lib/ddtrace/contrib/mongodb/patcher.rb +3 -0
- data/lib/ddtrace/contrib/rack/middlewares.rb +21 -35
- data/lib/ddtrace/contrib/rails/action_controller.rb +2 -2
- data/lib/ddtrace/contrib/rails/action_view.rb +2 -2
- data/lib/ddtrace/contrib/rails/active_record.rb +2 -2
- data/lib/ddtrace/contrib/rails/active_support.rb +2 -2
- data/lib/ddtrace/contrib/rails/framework.rb +36 -58
- data/lib/ddtrace/contrib/rails/middlewares.rb +1 -1
- data/lib/ddtrace/contrib/rails/patcher.rb +56 -0
- data/lib/ddtrace/contrib/rails/railtie.rb +18 -0
- data/lib/ddtrace/contrib/rails/utils.rb +1 -1
- data/lib/ddtrace/contrib/redis/patcher.rb +4 -0
- data/lib/ddtrace/contrib/redis/quantize.rb +1 -1
- data/lib/ddtrace/contrib/redis/tags.rb +1 -0
- data/lib/ddtrace/contrib/resque/patcher.rb +9 -0
- data/lib/ddtrace/contrib/resque/resque_job.rb +6 -6
- data/lib/ddtrace/contrib/sidekiq/tracer.rb +11 -11
- data/lib/ddtrace/contrib/sinatra/tracer.rb +23 -63
- data/lib/ddtrace/contrib/sucker_punch/patcher.rb +3 -0
- data/lib/ddtrace/ext/distributed.rb +2 -0
- data/lib/ddtrace/ext/redis.rb +6 -0
- data/lib/ddtrace/monkey.rb +20 -37
- data/lib/ddtrace/propagation/distributed_headers.rb +48 -0
- data/lib/ddtrace/propagation/http_propagator.rb +28 -0
- data/lib/ddtrace/registry.rb +42 -0
- data/lib/ddtrace/registry/registerable.rb +20 -0
- data/lib/ddtrace/sampler.rb +61 -1
- data/lib/ddtrace/sync_writer.rb +36 -0
- data/lib/ddtrace/tracer.rb +23 -21
- data/lib/ddtrace/transport.rb +52 -15
- data/lib/ddtrace/version.rb +2 -2
- data/lib/ddtrace/workers.rb +33 -31
- data/lib/ddtrace/writer.rb +20 -1
- metadata +42 -3
- data/lib/ddtrace/distributed.rb +0 -38
@@ -4,6 +4,9 @@ module Datadog
|
|
4
4
|
# Patcher enables patching of 'active_record' module.
|
5
5
|
# This is used in monkey.rb to manually apply patches
|
6
6
|
module Patcher
|
7
|
+
include Base
|
8
|
+
register_as :active_record, auto_patch: false
|
9
|
+
|
7
10
|
@patched = false
|
8
11
|
|
9
12
|
module_function
|
@@ -41,7 +44,7 @@ module Datadog
|
|
41
44
|
def self.datadog_trace
|
42
45
|
# TODO: Consider using patcher for Rails as well.
|
43
46
|
# @tracer ||= defined?(::Rails) && ::Rails.configuration.datadog_trace
|
44
|
-
@datadog_trace ||= defined?(::Sinatra) &&
|
47
|
+
@datadog_trace ||= defined?(::Sinatra) && Datadog.configuration[:sinatra].to_h
|
45
48
|
end
|
46
49
|
|
47
50
|
def self.adapter_name
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'ddtrace/registry'
|
2
|
+
require 'ddtrace/configurable'
|
3
|
+
|
4
|
+
module Datadog
|
5
|
+
module Contrib
|
6
|
+
# Base provides features that are shared across all integrations
|
7
|
+
module Base
|
8
|
+
def self.included(base)
|
9
|
+
base.send(:include, Registry::Registerable)
|
10
|
+
base.send(:include, Configurable)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -14,6 +14,9 @@ module Datadog
|
|
14
14
|
# Patcher enables patching of 'elasticsearch/transport' module.
|
15
15
|
# This is used in monkey.rb to automatically apply patches
|
16
16
|
module Patcher
|
17
|
+
include Base
|
18
|
+
register_as :elasticsearch, auto_patch: true
|
19
|
+
|
17
20
|
@patched = false
|
18
21
|
|
19
22
|
module_function
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'ddtrace/ext/http'
|
3
3
|
require 'ddtrace/ext/net'
|
4
|
-
require 'ddtrace/
|
4
|
+
require 'ddtrace/propagation/http_propagator'
|
5
5
|
|
6
6
|
module Datadog
|
7
7
|
module Contrib
|
8
8
|
module Faraday
|
9
9
|
# Middleware implements a faraday-middleware for ddtrace instrumentation
|
10
10
|
class Middleware < ::Faraday::Middleware
|
11
|
+
include Ext::DistributedTracing
|
12
|
+
|
11
13
|
DEFAULT_ERROR_HANDLER = lambda do |env|
|
12
14
|
Ext::HTTP::ERROR_RANGE.cover?(env[:status])
|
13
15
|
end
|
@@ -26,7 +28,7 @@ module Datadog
|
|
26
28
|
def call(env)
|
27
29
|
dd_pin.tracer.trace(SERVICE) do |span|
|
28
30
|
annotate!(span, env)
|
29
|
-
propagate!(span, env) if options[:distributed_tracing]
|
31
|
+
propagate!(span, env) if options[:distributed_tracing] && dd_pin.tracer.enabled
|
30
32
|
app.call(env).on_complete { |resp| handle_response(span, resp) }
|
31
33
|
end
|
32
34
|
end
|
@@ -54,10 +56,7 @@ module Datadog
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def propagate!(span, env)
|
57
|
-
env[:request_headers]
|
58
|
-
Ext::DistributedTracing::HTTP_HEADER_TRACE_ID => span.trace_id.to_s,
|
59
|
-
Ext::DistributedTracing::HTTP_HEADER_PARENT_ID => span.span_id.to_s
|
60
|
-
)
|
59
|
+
Datadog::HTTPPropagator.inject!(span.context, env[:request_headers])
|
61
60
|
end
|
62
61
|
|
63
62
|
def dd_pin
|
@@ -6,6 +6,9 @@ module Datadog
|
|
6
6
|
# Patcher that introduces more instrumentation for Grape endpoints, so that
|
7
7
|
# new signals are executed at the beginning of each step (filters, render and run)
|
8
8
|
module Patcher
|
9
|
+
include Base
|
10
|
+
register_as :grape, auto_patch: true
|
11
|
+
|
9
12
|
@patched = false
|
10
13
|
|
11
14
|
module_function
|
@@ -12,13 +12,17 @@ module Datadog
|
|
12
12
|
APP = 'net/http'.freeze
|
13
13
|
SERVICE = 'net/http'.freeze
|
14
14
|
|
15
|
-
|
15
|
+
module_function
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
# TODO: Remove this once we drop support for legacy configuration
|
18
|
+
def distributed_tracing_enabled
|
19
|
+
Datadog.configuration[:http][:distributed_tracing_enabled]
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
+
# TODO: Remove this once we drop support for legacy configuration
|
23
|
+
def distributed_tracing_enabled=(value)
|
24
|
+
Datadog.configuration[:http][:distributed_tracing_enabled] = value
|
25
|
+
end
|
22
26
|
|
23
27
|
def should_skip_tracing?(req, address, port, transport, pin)
|
24
28
|
# we don't want to trace our own call to the API (they use net/http)
|
@@ -42,15 +46,20 @@ module Datadog
|
|
42
46
|
end
|
43
47
|
|
44
48
|
def should_skip_distributed_tracing?(pin)
|
49
|
+
global_value = Datadog.configuration[:http][:distributed_tracing_enabled]
|
45
50
|
unless pin.config.nil?
|
46
|
-
return !pin.config.fetch(:distributed_tracing_enabled,
|
51
|
+
return !pin.config.fetch(:distributed_tracing_enabled, global_value)
|
47
52
|
end
|
48
|
-
|
53
|
+
!global_value
|
49
54
|
end
|
50
55
|
|
51
56
|
# Patcher enables patching of 'net/http' module.
|
52
57
|
# This is used in monkey.rb to automatically apply patches
|
53
58
|
module Patcher
|
59
|
+
include Base
|
60
|
+
register_as :http, auto_patch: true
|
61
|
+
option :distributed_tracing_enabled, default: false
|
62
|
+
|
54
63
|
@patched = false
|
55
64
|
|
56
65
|
module_function
|
@@ -120,9 +129,15 @@ module Datadog
|
|
120
129
|
span.set_tag(Datadog::Ext::HTTP::URL, req.path)
|
121
130
|
span.set_tag(Datadog::Ext::HTTP::METHOD, req.method)
|
122
131
|
|
123
|
-
|
132
|
+
if pin.tracer.enabled && !Datadog::Contrib::HTTP.should_skip_distributed_tracing?(pin)
|
124
133
|
req.add_field(Datadog::Ext::DistributedTracing::HTTP_HEADER_TRACE_ID, span.trace_id)
|
125
134
|
req.add_field(Datadog::Ext::DistributedTracing::HTTP_HEADER_PARENT_ID, span.span_id)
|
135
|
+
if span.context.sampling_priority
|
136
|
+
req.add_field(
|
137
|
+
Datadog::Ext::DistributedTracing::HTTP_HEADER_SAMPLING_PRIORITY,
|
138
|
+
span.context.sampling_priority
|
139
|
+
)
|
140
|
+
end
|
126
141
|
end
|
127
142
|
rescue StandardError => e
|
128
143
|
Datadog::Tracer.log.error("error preparing span for http request: #{e}")
|
@@ -1,41 +1,32 @@
|
|
1
1
|
require 'ddtrace/ext/app_types'
|
2
2
|
require 'ddtrace/ext/http'
|
3
|
-
require 'ddtrace/
|
3
|
+
require 'ddtrace/propagation/http_propagator'
|
4
4
|
|
5
5
|
module Datadog
|
6
6
|
module Contrib
|
7
7
|
# Rack module includes middlewares that are required to trace any framework
|
8
8
|
# and application built on top of Rack.
|
9
9
|
module Rack
|
10
|
-
# RACK headers to test when doing distributed tracing.
|
11
|
-
# They are slightly different from real headers as Rack uppercases everything
|
12
|
-
|
13
|
-
# Header used to transmit the trace ID.
|
14
|
-
HTTP_HEADER_TRACE_ID = 'HTTP_X_DATADOG_TRACE_ID'.freeze
|
15
|
-
|
16
|
-
# Header used to transmit the parent ID.
|
17
|
-
HTTP_HEADER_PARENT_ID = 'HTTP_X_DATADOG_PARENT_ID'.freeze
|
18
|
-
|
19
10
|
# TraceMiddleware ensures that the Rack Request is properly traced
|
20
11
|
# from the beginning to the end. The middleware adds the request span
|
21
12
|
# in the Rack environment so that it can be retrieved by the underlying
|
22
13
|
# application. If request tags are not set by the app, they will be set using
|
23
14
|
# information available at the Rack level.
|
24
15
|
class TraceMiddleware
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
include Base
|
17
|
+
register_as :rack
|
18
|
+
|
19
|
+
option :tracer, default: Datadog.tracer
|
20
|
+
option :default_service, default: 'rack'
|
21
|
+
option :distributed_tracing_enabled, default: false
|
30
22
|
|
31
23
|
def initialize(app, options = {})
|
32
24
|
# update options with our configuration, unless it's already available
|
33
25
|
[:tracer, :default_service, :distributed_tracing_enabled].each do |k|
|
34
|
-
options[k]
|
26
|
+
Datadog.configuration[:rack][k] = options[k] unless options[k].nil?
|
35
27
|
end
|
36
28
|
|
37
29
|
@app = app
|
38
|
-
@options = options
|
39
30
|
end
|
40
31
|
|
41
32
|
def configure
|
@@ -43,9 +34,9 @@ module Datadog
|
|
43
34
|
return clean_context if @tracer && @service
|
44
35
|
|
45
36
|
# retrieve the current tracer and service
|
46
|
-
@tracer =
|
47
|
-
@service =
|
48
|
-
@distributed_tracing_enabled =
|
37
|
+
@tracer = Datadog.configuration[:rack][:tracer]
|
38
|
+
@service = Datadog.configuration[:rack][:default_service]
|
39
|
+
@distributed_tracing_enabled = Datadog.configuration[:rack][:distributed_tracing_enabled]
|
49
40
|
|
50
41
|
# configure the Rack service
|
51
42
|
@tracer.set_service_info(
|
@@ -66,21 +57,16 @@ module Datadog
|
|
66
57
|
span_type: Datadog::Ext::HTTP::TYPE
|
67
58
|
}
|
68
59
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
#
|
77
|
-
#
|
78
|
-
|
79
|
-
env[Datadog::Contrib::Rack::HTTP_HEADER_TRACE_ID],
|
80
|
-
env[Datadog::Contrib::Rack::HTTP_HEADER_PARENT_ID]
|
81
|
-
)
|
82
|
-
request_span.trace_id = trace_id unless trace_id.nil?
|
83
|
-
request_span.parent_id = parent_id unless parent_id.nil?
|
60
|
+
request_span = nil
|
61
|
+
begin
|
62
|
+
if @distributed_tracing_enabled
|
63
|
+
context = HTTPPropagator.extract(env)
|
64
|
+
@tracer.provider.context = context if context.trace_id
|
65
|
+
end
|
66
|
+
ensure
|
67
|
+
# start a new request span and attach it to the current Rack environment;
|
68
|
+
# we must ensure that the span `resource` is set later
|
69
|
+
request_span = @tracer.trace('rack.request', trace_options)
|
84
70
|
end
|
85
71
|
|
86
72
|
env[:datadog_rack_request_span] = request_span
|
@@ -13,8 +13,8 @@ module Datadog
|
|
13
13
|
|
14
14
|
def self.start_processing(payload)
|
15
15
|
# trace the execution
|
16
|
-
tracer =
|
17
|
-
service =
|
16
|
+
tracer = Datadog.configuration[:rails][:tracer]
|
17
|
+
service = Datadog.configuration[:rails][:default_controller_service]
|
18
18
|
type = Datadog::Ext::HTTP::TYPE
|
19
19
|
span = tracer.trace('rails.action_controller', service: service, span_type: type)
|
20
20
|
|
@@ -15,7 +15,7 @@ module Datadog
|
|
15
15
|
tracing_context = payload.fetch(:tracing_context)
|
16
16
|
|
17
17
|
# create a new Span and add it to the tracing context
|
18
|
-
tracer =
|
18
|
+
tracer = Datadog.configuration[:rails][:tracer]
|
19
19
|
span = tracer.trace('rails.render_template', span_type: Datadog::Ext::HTTP::TEMPLATE)
|
20
20
|
tracing_context[:dd_rails_template_span] = span
|
21
21
|
rescue StandardError => e
|
@@ -48,7 +48,7 @@ module Datadog
|
|
48
48
|
# retrieve the tracing context
|
49
49
|
tracing_context = payload.fetch(:tracing_context)
|
50
50
|
|
51
|
-
tracer =
|
51
|
+
tracer = Datadog.configuration[:rails][:tracer]
|
52
52
|
span = tracer.trace('rails.render_partial', span_type: Datadog::Ext::HTTP::TEMPLATE)
|
53
53
|
tracing_context[:dd_rails_partial_span] = span
|
54
54
|
rescue StandardError => e
|
@@ -18,8 +18,8 @@ module Datadog
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.sql(_name, start, finish, _id, payload)
|
21
|
-
tracer =
|
22
|
-
database_service =
|
21
|
+
tracer = Datadog.configuration[:rails][:tracer]
|
22
|
+
database_service = Datadog.configuration[:rails][:default_database_service]
|
23
23
|
adapter_name = ::ActiveRecord::Base.connection_config[:adapter]
|
24
24
|
adapter_name = Datadog::Contrib::Rails::Utils.normalize_vendor(adapter_name)
|
25
25
|
span_type = Datadog::Ext::SQL::TYPE
|
@@ -12,7 +12,7 @@ module Datadog
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.start_trace_cache(payload)
|
15
|
-
tracer =
|
15
|
+
tracer = Datadog.configuration[:rails][:tracer]
|
16
16
|
tracing_context = payload.fetch(:tracing_context)
|
17
17
|
|
18
18
|
# In most of the cases Rails ``fetch()`` and ``read()`` calls are nested.
|
@@ -26,7 +26,7 @@ module Datadog
|
|
26
26
|
payload[:action] == 'GET'
|
27
27
|
|
28
28
|
# create a new ``Span`` and add it to the tracing context
|
29
|
-
service =
|
29
|
+
service = Datadog.configuration[:rails][:default_cache_service]
|
30
30
|
type = Datadog::Ext::CACHE::TYPE
|
31
31
|
span = tracer.trace('rails.cache', service: service, span_type: type)
|
32
32
|
span.resource = payload.fetch(:action)
|
@@ -30,82 +30,60 @@ module Datadog
|
|
30
30
|
# - handle configuration entries which are specific to Datadog tracing
|
31
31
|
# - instrument parts of the framework when needed
|
32
32
|
module Framework
|
33
|
-
# default configurations for the Rails integration; by default
|
34
|
-
# the Datadog.tracer is enabled, while the Rails auto instrumentation
|
35
|
-
# is kept disabled.
|
36
|
-
DEFAULT_CONFIG = {
|
37
|
-
enabled: true,
|
38
|
-
auto_instrument: false,
|
39
|
-
auto_instrument_redis: false,
|
40
|
-
auto_instrument_grape: false,
|
41
|
-
default_service: 'rails-app',
|
42
|
-
default_controller_service: 'rails-controller',
|
43
|
-
default_cache_service: 'rails-cache',
|
44
|
-
default_grape_service: 'grape',
|
45
|
-
template_base_path: 'views/',
|
46
|
-
tracer: Datadog.tracer,
|
47
|
-
debug: false,
|
48
|
-
trace_agent_hostname: Datadog::Writer::HOSTNAME,
|
49
|
-
trace_agent_port: Datadog::Writer::PORT,
|
50
|
-
env: nil,
|
51
|
-
tags: {}
|
52
|
-
}.freeze
|
53
|
-
|
54
33
|
# configure Datadog settings
|
55
34
|
# rubocop:disable Metrics/MethodLength
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
port: datadog_config[:trace_agent_port]
|
35
|
+
# rubocop:disable Metrics/AbcSize
|
36
|
+
def self.configure(rails_config)
|
37
|
+
user_config = rails_config[:config].datadog_trace rescue {}
|
38
|
+
Datadog.configuration.use(:rails, user_config)
|
39
|
+
tracer = Datadog.configuration[:rails][:tracer]
|
40
|
+
|
41
|
+
tracer.enabled = Datadog.configuration[:rails][:enabled]
|
42
|
+
tracer.class.debug_logging = Datadog.configuration[:rails][:debug]
|
43
|
+
|
44
|
+
tracer.configure(
|
45
|
+
hostname: Datadog.configuration[:rails][:trace_agent_hostname],
|
46
|
+
port: Datadog.configuration[:rails][:trace_agent_port],
|
47
|
+
priority_sampling: Datadog.configuration[:rails][:priority_sampling]
|
70
48
|
)
|
71
49
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
datadog_config[:tracer].set_tags('env' => datadog_config[:env]) if datadog_config[:env]
|
50
|
+
tracer.set_tags(Datadog.configuration[:rails][:tags])
|
51
|
+
tracer.set_tags('env' => Datadog.configuration[:rails][:env]) if Datadog.configuration[:rails][:env]
|
76
52
|
|
77
|
-
|
78
|
-
|
79
|
-
datadog_config[:default_service],
|
53
|
+
tracer.set_service_info(
|
54
|
+
Datadog.configuration[:rails][:default_service],
|
80
55
|
'rack',
|
81
56
|
Datadog::Ext::AppTypes::WEB
|
82
57
|
)
|
83
58
|
|
84
|
-
|
85
|
-
|
59
|
+
tracer.set_service_info(
|
60
|
+
Datadog.configuration[:rails][:default_controller_service],
|
86
61
|
'rails',
|
87
62
|
Datadog::Ext::AppTypes::WEB
|
88
63
|
)
|
89
|
-
|
90
|
-
|
91
|
-
datadog_config[:default_cache_service],
|
64
|
+
tracer.set_service_info(
|
65
|
+
Datadog.configuration[:rails][:default_cache_service],
|
92
66
|
'rails',
|
93
67
|
Datadog::Ext::AppTypes::CACHE
|
94
68
|
)
|
95
69
|
|
96
70
|
# By default, default service would be guessed from the script
|
97
71
|
# being executed, but here we know better, get it from Rails config.
|
98
|
-
|
72
|
+
tracer.default_service = Datadog.configuration[:rails][:default_service]
|
73
|
+
|
74
|
+
Datadog.configuration[:rack][:tracer] = tracer
|
75
|
+
Datadog.configuration[:rack][:default_service] = Datadog.configuration[:rails][:default_service]
|
76
|
+
Datadog.configuration[:rack][:distributed_tracing_enabled] = \
|
77
|
+
Datadog.configuration[:rails][:distributed_tracing_enabled]
|
99
78
|
|
100
79
|
if defined?(::ActiveRecord)
|
101
80
|
begin
|
102
81
|
# set default database service details and store it in the configuration
|
103
82
|
conn_cfg = ::ActiveRecord::Base.connection_config()
|
104
83
|
adapter_name = Datadog::Contrib::Rails::Utils.normalize_vendor(conn_cfg[:adapter])
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
database_service,
|
84
|
+
Datadog.configuration[:rails][:default_database_service] ||= adapter_name
|
85
|
+
tracer.set_service_info(
|
86
|
+
Datadog.configuration[:rails][:default_database_service],
|
109
87
|
adapter_name,
|
110
88
|
Datadog::Ext::AppTypes::DB
|
111
89
|
)
|
@@ -115,11 +93,11 @@ module Datadog
|
|
115
93
|
end
|
116
94
|
|
117
95
|
# update global configurations
|
118
|
-
::Rails.configuration.datadog_trace =
|
96
|
+
::Rails.configuration.datadog_trace = Datadog.registry[:rails].to_h
|
119
97
|
end
|
120
98
|
|
121
99
|
def self.auto_instrument_redis
|
122
|
-
return unless
|
100
|
+
return unless Datadog.configuration[:rails][:auto_instrument_redis]
|
123
101
|
Datadog::Tracer.log.debug('Enabling auto-instrumentation for Redis client')
|
124
102
|
|
125
103
|
# patch the Redis library and reload the CacheStore if it was using Redis
|
@@ -142,7 +120,7 @@ module Datadog
|
|
142
120
|
end
|
143
121
|
|
144
122
|
def self.auto_instrument_grape
|
145
|
-
return unless
|
123
|
+
return unless Datadog.configuration[:rails][:auto_instrument_grape]
|
146
124
|
|
147
125
|
# patch the Grape library so that endpoints are traced
|
148
126
|
Datadog::Monkey.patch_module(:grape)
|
@@ -150,13 +128,13 @@ module Datadog
|
|
150
128
|
# update the Grape pin object
|
151
129
|
pin = Datadog::Pin.get_from(::Grape)
|
152
130
|
return unless pin && pin.enabled?
|
153
|
-
pin.tracer =
|
154
|
-
pin.service =
|
131
|
+
pin.tracer = Datadog.configuration[:rails][:tracer]
|
132
|
+
pin.service = Datadog.configuration[:rails][:default_grape_service]
|
155
133
|
end
|
156
134
|
|
157
135
|
# automatically instrument all Rails component
|
158
136
|
def self.auto_instrument
|
159
|
-
return unless
|
137
|
+
return unless Datadog.configuration[:rails][:auto_instrument]
|
160
138
|
Datadog::Tracer.log.debug('Enabling auto-instrumentation for core components')
|
161
139
|
|
162
140
|
# instrumenting Rails framework
|