ddtrace 0.10.0 → 0.11.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ddtrace.gemspec +1 -1
- data/lib/ddtrace/configuration.rb +11 -1
- data/lib/ddtrace/contrib/active_record/patcher.rb +5 -9
- data/lib/ddtrace/contrib/aws/patcher.rb +2 -2
- data/lib/ddtrace/contrib/dalli/patcher.rb +2 -2
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +4 -1
- data/lib/ddtrace/contrib/faraday/patcher.rb +2 -0
- data/lib/ddtrace/contrib/grape/patcher.rb +3 -1
- data/lib/ddtrace/contrib/mongodb/patcher.rb +3 -1
- data/lib/ddtrace/contrib/rack/middlewares.rb +6 -8
- data/lib/ddtrace/contrib/rails/action_controller.rb +1 -1
- data/lib/ddtrace/contrib/rails/active_record.rb +1 -1
- data/lib/ddtrace/contrib/rails/active_support.rb +1 -1
- data/lib/ddtrace/contrib/rails/core_extensions.rb +20 -0
- data/lib/ddtrace/contrib/rails/framework.rb +16 -89
- data/lib/ddtrace/contrib/rails/patcher.rb +4 -16
- data/lib/ddtrace/contrib/rails/railtie.rb +4 -3
- data/lib/ddtrace/contrib/rails/utils.rb +8 -0
- data/lib/ddtrace/contrib/redis/patcher.rb +4 -2
- data/lib/ddtrace/contrib/resque/patcher.rb +2 -1
- data/lib/ddtrace/contrib/sidekiq/tracer.rb +5 -23
- data/lib/ddtrace/contrib/sinatra/tracer.rb +0 -14
- data/lib/ddtrace/contrib/sucker_punch/patcher.rb +2 -1
- data/lib/ddtrace/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97a9ed205c345e9abaa1b22823662552e52c898f
|
4
|
+
data.tar.gz: d3373c5a892cf5685ea2e360bcc2191702a358dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9601250c89c609412e3243f26e43052b6d71c47861adb4f4dbf424d66507f39d97b95bc8ce514a6e2554d18b8fd5cf5dc98d88894d7ff0f14912a11eef5b696c
|
7
|
+
data.tar.gz: 663044f68bc969e7510740c88218875021aec925dbb458bb28bac7f81765d0fe0873c226301b2dbca813d097f2e7ee94e988e71eb5bbd24a381b16c4a6c71fc4
|
data/ddtrace.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'ddtrace/version'
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'ddtrace'
|
9
|
-
spec.version = "#{Datadog::VERSION::STRING}#{ENV['VERSION_SUFFIX']}"
|
9
|
+
spec.version = "#{Datadog::VERSION::STRING}.beta1#{ENV['VERSION_SUFFIX']}"
|
10
10
|
spec.required_ruby_version = '>= 1.9.1'
|
11
11
|
spec.authors = ['Datadog, Inc.']
|
12
12
|
spec.email = ['dev@datadoghq.com']
|
@@ -17,14 +17,24 @@ module Datadog
|
|
17
17
|
|
18
18
|
def use(integration_name, options = {})
|
19
19
|
integration = fetch_integration(integration_name)
|
20
|
+
settings = Proxy.new(integration)
|
20
21
|
|
21
22
|
integration.sorted_options.each do |name|
|
22
|
-
|
23
|
+
settings[name] = options.fetch(name, settings[name])
|
23
24
|
end
|
24
25
|
|
25
26
|
integration.patch if integration.respond_to?(:patch)
|
26
27
|
end
|
27
28
|
|
29
|
+
def tracer(options = {})
|
30
|
+
instance = options.fetch(:instance, Datadog.tracer)
|
31
|
+
|
32
|
+
instance.configure(options)
|
33
|
+
instance.set_tags(options[:tags]) if options[:tags]
|
34
|
+
instance.set_tags(env: options[:env]) if options[:env]
|
35
|
+
instance.class.debug_logging = options.fetch(:debug, false)
|
36
|
+
end
|
37
|
+
|
28
38
|
private
|
29
39
|
|
30
40
|
def fetch_integration(name)
|
@@ -6,6 +6,7 @@ module Datadog
|
|
6
6
|
module Patcher
|
7
7
|
include Base
|
8
8
|
register_as :active_record, auto_patch: false
|
9
|
+
option :service_name
|
9
10
|
|
10
11
|
@patched = false
|
11
12
|
|
@@ -59,15 +60,10 @@ module Datadog
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def self.database_service
|
62
|
-
@database_service
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
if @database_service
|
68
|
-
tracer().set_service_info(@database_service, 'sinatra',
|
69
|
-
Datadog::Ext::AppTypes::DB)
|
70
|
-
end
|
63
|
+
return @database_service if defined?(@database_service)
|
64
|
+
|
65
|
+
@database_service = get_option(:service_name) || adapter_name
|
66
|
+
tracer.set_service_info(@database_service, 'sinatra', Ext::AppTypes::DB)
|
71
67
|
@database_service
|
72
68
|
end
|
73
69
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Datadog
|
2
2
|
module Contrib
|
3
3
|
module Aws
|
4
|
-
SERVICE = 'aws'.freeze
|
5
4
|
AGENT = 'aws-sdk-ruby'.freeze
|
6
5
|
RESOURCE = 'aws.command'.freeze
|
7
6
|
|
@@ -9,6 +8,7 @@ module Datadog
|
|
9
8
|
module Patcher
|
10
9
|
include Base
|
11
10
|
register_as :aws, auto_patch: true
|
11
|
+
option :service_name, default: 'aws'
|
12
12
|
|
13
13
|
@patched = false
|
14
14
|
|
@@ -37,7 +37,7 @@ module Datadog
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def add_pin
|
40
|
-
Pin.new(
|
40
|
+
Pin.new(get_option(:service_name), app_type: Ext::AppTypes::WEB).tap do |pin|
|
41
41
|
pin.onto(::Aws)
|
42
42
|
end
|
43
43
|
end
|
@@ -2,7 +2,6 @@ module Datadog
|
|
2
2
|
module Contrib
|
3
3
|
module Dalli
|
4
4
|
COMPATIBLE_WITH = Gem::Version.new('2.0.0')
|
5
|
-
SERVICE = 'memcached'.freeze
|
6
5
|
NAME = 'memcached.command'.freeze
|
7
6
|
CMD_TAG = 'memcached.command'.freeze
|
8
7
|
|
@@ -10,6 +9,7 @@ module Datadog
|
|
10
9
|
module Patcher
|
11
10
|
include Base
|
12
11
|
register_as :dalli, auto_patch: true
|
12
|
+
option :service_name, default: 'memcached'
|
13
13
|
|
14
14
|
@patched = false
|
15
15
|
|
@@ -42,7 +42,7 @@ module Datadog
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def add_pin!
|
45
|
-
Pin.new(
|
45
|
+
Pin.new(get_option(:service_name), app_type: Ext::AppTypes::DB).tap do |pin|
|
46
46
|
pin.onto(::Dalli)
|
47
47
|
end
|
48
48
|
end
|
@@ -16,6 +16,7 @@ module Datadog
|
|
16
16
|
module Patcher
|
17
17
|
include Base
|
18
18
|
register_as :elasticsearch, auto_patch: true
|
19
|
+
option :service_name, default: SERVICE
|
19
20
|
|
20
21
|
@patched = false
|
21
22
|
|
@@ -45,6 +46,7 @@ module Datadog
|
|
45
46
|
|
46
47
|
# rubocop:disable Metrics/MethodLength
|
47
48
|
def patch_elasticsearch_transport_client
|
49
|
+
# rubocop:disable Metrics/BlockLength
|
48
50
|
::Elasticsearch::Transport::Client.class_eval do
|
49
51
|
alias_method :initialize_without_datadog, :initialize
|
50
52
|
Datadog::Monkey.without_warnings do
|
@@ -52,7 +54,8 @@ module Datadog
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def initialize(*args)
|
55
|
-
|
57
|
+
service = Datadog.configuration[:elasticsearch][:service_name]
|
58
|
+
pin = Datadog::Pin.new(service, app: 'elasticsearch', app_type: Datadog::Ext::AppTypes::DB)
|
56
59
|
pin.onto(self)
|
57
60
|
initialize_without_datadog(*args)
|
58
61
|
end
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
module Patcher
|
9
9
|
include Base
|
10
10
|
register_as :faraday, auto_patch: true
|
11
|
+
option :service_name, default: SERVICE
|
11
12
|
|
12
13
|
@patched = false
|
13
14
|
|
@@ -42,6 +43,7 @@ module Datadog
|
|
42
43
|
def add_pin
|
43
44
|
Pin.new(SERVICE, app_type: Ext::AppTypes::WEB).tap do |pin|
|
44
45
|
pin.onto(::Faraday)
|
46
|
+
pin.service = Datadog.configuration[:faraday][:service_name]
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
module Patcher
|
9
9
|
include Base
|
10
10
|
register_as :grape, auto_patch: true
|
11
|
+
option :service_name, default: SERVICE
|
11
12
|
|
12
13
|
@patched = false
|
13
14
|
|
@@ -31,7 +32,8 @@ module Datadog
|
|
31
32
|
patch_endpoint_render()
|
32
33
|
|
33
34
|
# attach a PIN object globally and set the service once
|
34
|
-
|
35
|
+
service = get_option(:service_name)
|
36
|
+
pin = Datadog::Pin.new(service, app: 'grape', app_type: Datadog::Ext::AppTypes::WEB)
|
35
37
|
pin.onto(::Grape)
|
36
38
|
if pin.tracer && pin.service
|
37
39
|
pin.tracer.set_service_info(pin.service, 'grape', pin.app_type)
|
@@ -13,6 +13,7 @@ module Datadog
|
|
13
13
|
module Patcher
|
14
14
|
include Base
|
15
15
|
register_as :mongo, auto_patch: true
|
16
|
+
option :service_name, default: SERVICE
|
16
17
|
|
17
18
|
@patched = false
|
18
19
|
|
@@ -63,7 +64,8 @@ module Datadog
|
|
63
64
|
def initialize(*args, &blk)
|
64
65
|
# attach the Pin instance
|
65
66
|
initialize_without_datadog(*args, &blk)
|
66
|
-
|
67
|
+
service = Datadog.configuration[:mongo][:service_name]
|
68
|
+
pin = Datadog::Pin.new(service, app: APP, app_type: Datadog::Ext::AppTypes::DB)
|
67
69
|
pin.onto(self)
|
68
70
|
if pin.tracer && pin.service
|
69
71
|
pin.tracer.set_service_info(pin.service, 'mongodb', pin.app_type)
|
@@ -17,12 +17,15 @@ module Datadog
|
|
17
17
|
register_as :rack
|
18
18
|
|
19
19
|
option :tracer, default: Datadog.tracer
|
20
|
-
option :
|
20
|
+
option :service_name, default: 'rack', depends_on: [:tracer] do |value|
|
21
|
+
get_option(:tracer).set_service_info(value, 'rack', Ext::AppTypes::WEB)
|
22
|
+
value
|
23
|
+
end
|
21
24
|
option :distributed_tracing_enabled, default: false
|
22
25
|
|
23
26
|
def initialize(app, options = {})
|
24
27
|
# update options with our configuration, unless it's already available
|
25
|
-
[:tracer, :
|
28
|
+
[:tracer, :service_name, :distributed_tracing_enabled].each do |k|
|
26
29
|
Datadog.configuration[:rack][k] = options[k] unless options[k].nil?
|
27
30
|
end
|
28
31
|
|
@@ -35,15 +38,10 @@ module Datadog
|
|
35
38
|
|
36
39
|
# retrieve the current tracer and service
|
37
40
|
@tracer = Datadog.configuration[:rack][:tracer]
|
38
|
-
@service = Datadog.configuration[:rack][:
|
41
|
+
@service = Datadog.configuration[:rack][:service_name]
|
39
42
|
@distributed_tracing_enabled = Datadog.configuration[:rack][:distributed_tracing_enabled]
|
40
43
|
|
41
44
|
# configure the Rack service
|
42
|
-
@tracer.set_service_info(
|
43
|
-
@service,
|
44
|
-
'rack',
|
45
|
-
Datadog::Ext::AppTypes::WEB
|
46
|
-
)
|
47
45
|
end
|
48
46
|
|
49
47
|
# rubocop:disable Metrics/MethodLength
|
@@ -14,7 +14,7 @@ module Datadog
|
|
14
14
|
def self.start_processing(payload)
|
15
15
|
# trace the execution
|
16
16
|
tracer = Datadog.configuration[:rails][:tracer]
|
17
|
-
service = Datadog.configuration[:rails][:
|
17
|
+
service = Datadog.configuration[:rails][:controller_service]
|
18
18
|
type = Datadog::Ext::HTTP::TYPE
|
19
19
|
span = tracer.trace('rails.action_controller', service: service, span_type: type)
|
20
20
|
|
@@ -19,7 +19,7 @@ module Datadog
|
|
19
19
|
|
20
20
|
def self.sql(_name, start, finish, _id, payload)
|
21
21
|
tracer = Datadog.configuration[:rails][:tracer]
|
22
|
-
database_service = Datadog.configuration[:rails][:
|
22
|
+
database_service = Datadog.configuration[:rails][: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
|
@@ -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 = Datadog.configuration[:rails][:
|
29
|
+
service = Datadog.configuration[:rails][: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)
|
@@ -168,6 +168,7 @@ module Datadog
|
|
168
168
|
patch_cache_store_fetch
|
169
169
|
patch_cache_store_write
|
170
170
|
patch_cache_store_delete
|
171
|
+
reload_cache_store
|
171
172
|
end
|
172
173
|
|
173
174
|
def cache_store_class(k)
|
@@ -285,5 +286,24 @@ module Datadog
|
|
285
286
|
end
|
286
287
|
end
|
287
288
|
end
|
289
|
+
|
290
|
+
def self.reload_cache_store
|
291
|
+
return unless Datadog.registry[:redis].patched?
|
292
|
+
|
293
|
+
return unless defined?(::ActiveSupport::Cache::RedisStore) &&
|
294
|
+
defined?(::Rails.cache) &&
|
295
|
+
::Rails.cache.is_a?(::ActiveSupport::Cache::RedisStore)
|
296
|
+
|
297
|
+
Tracer.log.debug('Reloading redis cache store')
|
298
|
+
|
299
|
+
# backward compatibility: Rails 3.x doesn't have `cache=` method
|
300
|
+
cache_store = ::Rails.configuration.cache_store
|
301
|
+
cache_instance = ::ActiveSupport::Cache.lookup_store(cache_store)
|
302
|
+
if ::Rails::VERSION::MAJOR.to_i == 3
|
303
|
+
silence_warnings { Object.const_set 'RAILS_CACHE', cache_instance }
|
304
|
+
elsif ::Rails::VERSION::MAJOR.to_i > 3
|
305
|
+
::Rails.cache = cache_instance
|
306
|
+
end
|
307
|
+
end
|
288
308
|
end
|
289
309
|
end
|
@@ -31,62 +31,37 @@ module Datadog
|
|
31
31
|
# - instrument parts of the framework when needed
|
32
32
|
module Framework
|
33
33
|
# configure Datadog settings
|
34
|
-
# rubocop:disable Metrics/MethodLength
|
35
|
-
# rubocop:disable Metrics/AbcSize
|
36
34
|
def self.configure(rails_config)
|
37
35
|
user_config = rails_config[:config].datadog_trace rescue {}
|
38
36
|
Datadog.configuration.use(:rails, user_config)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
config = Datadog.configuration[:rails]
|
38
|
+
tracer = config[:tracer]
|
39
|
+
config[:service_name] ||= Utils.app_name
|
40
|
+
|
41
|
+
Datadog.configuration.use(
|
42
|
+
:rack,
|
43
|
+
tracer: tracer,
|
44
|
+
service_name: config[:service_name],
|
45
|
+
distributed_tracing_enabled: config[:distributed_tracing_enabled]
|
48
46
|
)
|
49
47
|
|
50
|
-
|
51
|
-
|
48
|
+
config[:controller_service] ||= config[:service_name]
|
49
|
+
config[:cache_service] ||= "#{config[:service_name]}-cache"
|
52
50
|
|
53
|
-
tracer.set_service_info(
|
54
|
-
|
55
|
-
'rack',
|
56
|
-
Datadog::Ext::AppTypes::WEB
|
57
|
-
)
|
58
|
-
|
59
|
-
tracer.set_service_info(
|
60
|
-
Datadog.configuration[:rails][:default_controller_service],
|
61
|
-
'rails',
|
62
|
-
Datadog::Ext::AppTypes::WEB
|
63
|
-
)
|
64
|
-
tracer.set_service_info(
|
65
|
-
Datadog.configuration[:rails][:default_cache_service],
|
66
|
-
'rails',
|
67
|
-
Datadog::Ext::AppTypes::CACHE
|
68
|
-
)
|
51
|
+
tracer.set_service_info(config[:controller_service], 'rails', Ext::AppTypes::WEB)
|
52
|
+
tracer.set_service_info(config[:cache_service], 'rails', Ext::AppTypes::CACHE)
|
69
53
|
|
70
54
|
# By default, default service would be guessed from the script
|
71
55
|
# being executed, but here we know better, get it from Rails config.
|
72
|
-
tracer.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]
|
56
|
+
tracer.default_service = config[:service_name]
|
78
57
|
|
79
58
|
if defined?(::ActiveRecord)
|
80
59
|
begin
|
81
60
|
# set default database service details and store it in the configuration
|
82
61
|
conn_cfg = ::ActiveRecord::Base.connection_config()
|
83
62
|
adapter_name = Datadog::Contrib::Rails::Utils.normalize_vendor(conn_cfg[:adapter])
|
84
|
-
|
85
|
-
tracer.set_service_info(
|
86
|
-
Datadog.configuration[:rails][:default_database_service],
|
87
|
-
adapter_name,
|
88
|
-
Datadog::Ext::AppTypes::DB
|
89
|
-
)
|
63
|
+
config[:database_service] ||= "#{config[:service_name]}-#{adapter_name}"
|
64
|
+
tracer.set_service_info(config[:database_service], adapter_name, Ext::AppTypes::DB)
|
90
65
|
rescue StandardError => e
|
91
66
|
Datadog::Tracer.log.warn("Unable to get database config (#{e}), skipping ActiveRecord instrumentation")
|
92
67
|
end
|
@@ -95,54 +70,6 @@ module Datadog
|
|
95
70
|
# update global configurations
|
96
71
|
::Rails.configuration.datadog_trace = Datadog.registry[:rails].to_h
|
97
72
|
end
|
98
|
-
|
99
|
-
def self.auto_instrument_redis
|
100
|
-
return unless Datadog.configuration[:rails][:auto_instrument_redis]
|
101
|
-
Datadog::Tracer.log.debug('Enabling auto-instrumentation for Redis client')
|
102
|
-
|
103
|
-
# patch the Redis library and reload the CacheStore if it was using Redis
|
104
|
-
Datadog::Monkey.patch_module(:redis)
|
105
|
-
|
106
|
-
# reload the cache store if it's available and it's using Redis
|
107
|
-
return unless defined?(::ActiveSupport::Cache::RedisStore) &&
|
108
|
-
defined?(::Rails.cache) &&
|
109
|
-
::Rails.cache.is_a?(::ActiveSupport::Cache::RedisStore)
|
110
|
-
Datadog::Tracer.log.debug('Enabling auto-instrumentation for redis-rails connector')
|
111
|
-
|
112
|
-
# backward compatibility: Rails 3.x doesn't have `cache=` method
|
113
|
-
cache_store = ::Rails.configuration.cache_store
|
114
|
-
cache_instance = ::ActiveSupport::Cache.lookup_store(cache_store)
|
115
|
-
if ::Rails::VERSION::MAJOR.to_i == 3
|
116
|
-
silence_warnings { Object.const_set 'RAILS_CACHE', cache_instance }
|
117
|
-
elsif ::Rails::VERSION::MAJOR.to_i > 3
|
118
|
-
::Rails.cache = cache_instance
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.auto_instrument_grape
|
123
|
-
return unless Datadog.configuration[:rails][:auto_instrument_grape]
|
124
|
-
|
125
|
-
# patch the Grape library so that endpoints are traced
|
126
|
-
Datadog::Monkey.patch_module(:grape)
|
127
|
-
|
128
|
-
# update the Grape pin object
|
129
|
-
pin = Datadog::Pin.get_from(::Grape)
|
130
|
-
return unless pin && pin.enabled?
|
131
|
-
pin.tracer = Datadog.configuration[:rails][:tracer]
|
132
|
-
pin.service = Datadog.configuration[:rails][:default_grape_service]
|
133
|
-
end
|
134
|
-
|
135
|
-
# automatically instrument all Rails component
|
136
|
-
def self.auto_instrument
|
137
|
-
return unless Datadog.configuration[:rails][:auto_instrument]
|
138
|
-
Datadog::Tracer.log.debug('Enabling auto-instrumentation for core components')
|
139
|
-
|
140
|
-
# instrumenting Rails framework
|
141
|
-
Datadog::Contrib::Rails::ActionController.instrument()
|
142
|
-
Datadog::Contrib::Rails::ActionView.instrument()
|
143
|
-
Datadog::Contrib::Rails::ActiveRecord.instrument()
|
144
|
-
Datadog::Contrib::Rails::ActiveSupport.instrument()
|
145
|
-
end
|
146
73
|
end
|
147
74
|
end
|
148
75
|
end
|
@@ -6,25 +6,13 @@ module Datadog
|
|
6
6
|
include Base
|
7
7
|
register_as :rails, auto_patch: true
|
8
8
|
|
9
|
-
option :
|
10
|
-
option :
|
11
|
-
option :
|
12
|
-
option :
|
13
|
-
option :default_service, default: 'rails-app'
|
14
|
-
option :default_controller_service, default: 'rails-controller'
|
15
|
-
option :default_cache_service, default: 'rails-cache'
|
16
|
-
option :default_grape_service, default: 'grape'
|
17
|
-
option :default_database_service
|
9
|
+
option :service_name
|
10
|
+
option :controller_service
|
11
|
+
option :cache_service
|
12
|
+
option :database_service
|
18
13
|
option :distributed_tracing_enabled, default: false
|
19
|
-
option :priority_sampling, default: false
|
20
14
|
option :template_base_path, default: 'views/'
|
21
15
|
option :tracer, default: Datadog.tracer
|
22
|
-
option :debug, default: false
|
23
|
-
option :trace_agent_hostname, default: Datadog::Writer::HOSTNAME
|
24
|
-
option :trace_agent_port, default: Datadog::Writer::PORT
|
25
|
-
option :env, default: nil
|
26
|
-
option :tags, default: {}
|
27
|
-
option :sidekiq_service, default: 'sidekiq'
|
28
16
|
|
29
17
|
@patched = false
|
30
18
|
|
@@ -10,9 +10,10 @@ module Datadog
|
|
10
10
|
|
11
11
|
config.after_initialize do |app|
|
12
12
|
Datadog::Contrib::Rails::Framework.configure(config: app.config)
|
13
|
-
Datadog::Contrib::Rails::
|
14
|
-
Datadog::Contrib::Rails::
|
15
|
-
Datadog::Contrib::Rails::
|
13
|
+
Datadog::Contrib::Rails::ActionController.instrument
|
14
|
+
Datadog::Contrib::Rails::ActionView.instrument
|
15
|
+
Datadog::Contrib::Rails::ActiveRecord.instrument
|
16
|
+
Datadog::Contrib::Rails::ActiveSupport.instrument
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -11,6 +11,7 @@ module Datadog
|
|
11
11
|
module Patcher
|
12
12
|
include Base
|
13
13
|
register_as :redis, auto_patch: true
|
14
|
+
option :service_name, default: SERVICE
|
14
15
|
|
15
16
|
@patched = false
|
16
17
|
|
@@ -29,8 +30,8 @@ module Datadog
|
|
29
30
|
|
30
31
|
patch_redis()
|
31
32
|
patch_redis_client()
|
32
|
-
|
33
33
|
@patched = true
|
34
|
+
RailsCachePatcher.reload_cache_store if Datadog.registry[:rails].patched?
|
34
35
|
rescue StandardError => e
|
35
36
|
Datadog::Tracer.log.error("Unable to apply Redis integration: #{e}")
|
36
37
|
end
|
@@ -62,7 +63,8 @@ module Datadog
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def initialize(*args)
|
65
|
-
|
66
|
+
service = Datadog.configuration[:redis][:service_name]
|
67
|
+
pin = Datadog::Pin.new(service, app: 'redis', app_type: Datadog::Ext::AppTypes::DB)
|
66
68
|
pin.onto(self)
|
67
69
|
if pin.tracer && pin.service
|
68
70
|
pin.tracer.set_service_info(pin.service, pin.app, pin.app_type)
|
@@ -13,6 +13,7 @@ module Datadog
|
|
13
13
|
module Patcher
|
14
14
|
include Base
|
15
15
|
register_as :resque, auto_patch: true
|
16
|
+
option :service_name, default: SERVICE
|
16
17
|
|
17
18
|
@patched = false
|
18
19
|
|
@@ -36,7 +37,7 @@ module Datadog
|
|
36
37
|
private
|
37
38
|
|
38
39
|
def add_pin
|
39
|
-
Pin.new(
|
40
|
+
Pin.new(get_option(:service_name), app_type: Ext::AppTypes::WORKER).tap do |pin|
|
40
41
|
pin.onto(::Resque)
|
41
42
|
end
|
42
43
|
end
|
@@ -18,31 +18,13 @@ module Datadog
|
|
18
18
|
class Tracer
|
19
19
|
include Base
|
20
20
|
register_as :sidekiq
|
21
|
-
|
22
|
-
option :enabled, default: true
|
23
|
-
option :sidekiq_service, default: 'sidekiq'
|
21
|
+
option :service_name, default: 'sidekiq'
|
24
22
|
option :tracer, default: Datadog.tracer
|
25
|
-
option :debug, default: false
|
26
|
-
option :trace_agent_hostname, default: Writer::HOSTNAME
|
27
|
-
option :trace_agent_port, default: Writer::PORT
|
28
23
|
|
29
24
|
def initialize(options = {})
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
user_config = base_config.merge(options)
|
34
|
-
@tracer = user_config[:tracer]
|
35
|
-
@sidekiq_service = user_config[:sidekiq_service]
|
36
|
-
|
37
|
-
# set Tracer status
|
38
|
-
@tracer.enabled = user_config[:enabled]
|
39
|
-
Datadog::Tracer.debug_logging = user_config[:debug]
|
40
|
-
|
41
|
-
# configure the Tracer instance
|
42
|
-
@tracer.configure(
|
43
|
-
hostname: user_config[:trace_agent_hostname],
|
44
|
-
port: user_config[:trace_agent_port]
|
45
|
-
)
|
25
|
+
config = Datadog.configuration[:sidekiq].merge(options)
|
26
|
+
@tracer = config[:tracer]
|
27
|
+
@sidekiq_service = config[:service_name]
|
46
28
|
end
|
47
29
|
|
48
30
|
def call(worker, job, queue)
|
@@ -86,7 +68,7 @@ module Datadog
|
|
86
68
|
end
|
87
69
|
|
88
70
|
def sidekiq_service(resource)
|
89
|
-
worker_config(resource).fetch(:
|
71
|
+
worker_config(resource).fetch(:service_name, @sidekiq_service)
|
90
72
|
end
|
91
73
|
|
92
74
|
def set_service_info(service)
|
@@ -23,10 +23,6 @@ module Datadog
|
|
23
23
|
include Base
|
24
24
|
register_as :sinatra
|
25
25
|
|
26
|
-
option :enabled, default: true, depends_on: [:tracer] do |value|
|
27
|
-
get_option(:tracer).enabled = value
|
28
|
-
end
|
29
|
-
|
30
26
|
option :service_name, default: 'sinatra', depends_on: [:tracer] do |value|
|
31
27
|
get_option(:tracer).set_service_info(value, 'sinatra', Ext::AppTypes::WEB)
|
32
28
|
value
|
@@ -34,16 +30,6 @@ module Datadog
|
|
34
30
|
|
35
31
|
option :tracer, default: Datadog.tracer
|
36
32
|
|
37
|
-
option(:debug, default: false) { |value| Tracer.debug_logging = value }
|
38
|
-
|
39
|
-
option :trace_agent_hostname, default: Writer::HOSTNAME, depends_on: [:tracer] do |value|
|
40
|
-
get_option(:tracer).configure(hostname: value)
|
41
|
-
end
|
42
|
-
|
43
|
-
option :trace_agent_port, default: Writer::PORT, depends_on: [:tracer] do |value|
|
44
|
-
get_option(:tracer).configure(port: value)
|
45
|
-
end
|
46
|
-
|
47
33
|
def route(verb, action, *)
|
48
34
|
# Keep track of the route name when the app is instantiated for an
|
49
35
|
# incoming request.
|
@@ -8,6 +8,7 @@ module Datadog
|
|
8
8
|
module Patcher
|
9
9
|
include Base
|
10
10
|
register_as :sucker_punch, auto_patch: true
|
11
|
+
option :service_name, default: SERVICE
|
11
12
|
|
12
13
|
@patched = false
|
13
14
|
|
@@ -41,7 +42,7 @@ module Datadog
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def add_pin!
|
44
|
-
Pin.new(
|
45
|
+
Pin.new(get_option(:service_name), app_type: Ext::AppTypes::WORKER).tap do |pin|
|
45
46
|
pin.onto(::SuckerPunch)
|
46
47
|
end
|
47
48
|
end
|
data/lib/ddtrace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddtrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -269,9 +269,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
269
269
|
version: 1.9.1
|
270
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
271
|
requirements:
|
272
|
-
- - "
|
272
|
+
- - ">"
|
273
273
|
- !ruby/object:Gem::Version
|
274
|
-
version:
|
274
|
+
version: 1.3.1
|
275
275
|
requirements: []
|
276
276
|
rubyforge_project:
|
277
277
|
rubygems_version: 2.6.9
|