ddtrace 0.13.2 → 0.14.0.beta1
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/.rubocop.yml +10 -0
- data/Appraisals +12 -0
- data/CHANGELOG.md +16 -5
- data/Rakefile +18 -1
- data/docs/GettingStarted.md +63 -0
- data/lib/ddtrace.rb +3 -1
- data/lib/ddtrace/configuration.rb +18 -6
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +46 -0
- data/lib/ddtrace/contrib/active_record/configuration/settings.rb +28 -0
- data/lib/ddtrace/contrib/active_record/events/sql.rb +11 -7
- data/lib/ddtrace/contrib/active_record/integration.rb +44 -0
- data/lib/ddtrace/contrib/active_record/patcher.rb +4 -28
- data/lib/ddtrace/contrib/active_record/utils.rb +5 -11
- data/lib/ddtrace/contrib/base.rb +4 -3
- data/lib/ddtrace/contrib/configurable.rb +55 -0
- data/lib/ddtrace/contrib/configuration/option.rb +33 -0
- data/lib/ddtrace/contrib/configuration/option_definition.rb +29 -0
- data/lib/ddtrace/contrib/configuration/option_definition_set.rb +20 -0
- data/lib/ddtrace/contrib/configuration/option_set.rb +8 -0
- data/lib/ddtrace/contrib/configuration/options.rb +95 -0
- data/lib/ddtrace/contrib/configuration/resolver.rb +12 -0
- data/lib/ddtrace/contrib/configuration/settings.rb +35 -0
- data/lib/ddtrace/contrib/delayed_job/patcher.rb +41 -0
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +43 -0
- data/lib/ddtrace/contrib/integration.rb +16 -0
- data/lib/ddtrace/contrib/patchable.rb +38 -0
- data/lib/ddtrace/contrib/patcher.rb +28 -0
- data/lib/ddtrace/contrib/rake/instrumentation.rb +3 -15
- data/lib/ddtrace/contrib/registerable.rb +33 -0
- data/lib/ddtrace/contrib/resque/resque_job.rb +2 -10
- data/lib/ddtrace/contrib/sequel/configuration/settings.rb +13 -0
- data/lib/ddtrace/contrib/sequel/database.rb +1 -1
- data/lib/ddtrace/contrib/sequel/integration.rb +38 -0
- data/lib/ddtrace/contrib/sequel/patcher.rb +4 -20
- data/lib/ddtrace/patcher.rb +5 -0
- data/lib/ddtrace/propagation/http_propagator.rb +0 -6
- data/lib/ddtrace/tracer.rb +17 -5
- data/lib/ddtrace/vendor/active_record/connection_specification.rb +301 -0
- data/lib/ddtrace/version.rb +3 -3
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92f58d3f94ff927d412151da041ce48c3c808c3aa8b4c7a2f320c2206daad363
|
4
|
+
data.tar.gz: f0f9308f6e1eaba46afc42f7237faea5587cd4d4071410547d798c79f8988602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06d6974ee82c2e0f1c72edbb86b0ba03a6fefe4d383b704f93ff2d2f9416bab39b520a4a9cd8458c2977be878b32d69743ae77c4170583d1a2615d1aaca070a3
|
7
|
+
data.tar.gz: d54d30913137f1892adb625faaa39b4c1c49b4f70c7d1750a477df3e532a34559e4731a27a7faadfad7a50793584862bde3acf801e2ab059533bf2a6b17af468
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.1
|
3
|
+
Include:
|
4
|
+
- 'lib/**/*.rb'
|
5
|
+
- 'test/**/*.rb'
|
6
|
+
- 'spec/**/*.rb'
|
7
|
+
- 'Gemfile'
|
8
|
+
- 'Rakefile'
|
9
|
+
Exclude:
|
10
|
+
- 'Appraisals'
|
11
|
+
- '*.gemspec'
|
12
|
+
- 'lib/ddtrace/vendor/**/*.rb'
|
3
13
|
|
4
14
|
# 80 characters is a nice goal, but not worth currently changing in existing
|
5
15
|
# code for the sake of changing it to conform to a length set in 1928 (IBM).
|
data/Appraisals
CHANGED
@@ -68,6 +68,8 @@ elsif Gem::Version.new('1.9.3') <= Gem::Version.new(RUBY_VERSION) \
|
|
68
68
|
gem 'activerecord-mysql-adapter', platform: :ruby
|
69
69
|
gem 'aws-sdk', '~> 2.0'
|
70
70
|
gem 'dalli'
|
71
|
+
gem 'delayed_job'
|
72
|
+
gem 'delayed_job_active_record'
|
71
73
|
gem 'elasticsearch-transport'
|
72
74
|
gem 'excon'
|
73
75
|
gem 'hiredis'
|
@@ -148,6 +150,8 @@ elsif Gem::Version.new('2.0.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
148
150
|
gem 'activerecord-mysql-adapter', platform: :ruby
|
149
151
|
gem 'aws-sdk', '~> 2.0'
|
150
152
|
gem 'dalli'
|
153
|
+
gem 'delayed_job'
|
154
|
+
gem 'delayed_job_active_record'
|
151
155
|
gem 'elasticsearch-transport'
|
152
156
|
gem 'excon'
|
153
157
|
gem 'hiredis'
|
@@ -248,6 +252,8 @@ elsif Gem::Version.new('2.1.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
248
252
|
gem 'activerecord-mysql-adapter', platform: :ruby
|
249
253
|
gem 'aws-sdk', '~> 2.0'
|
250
254
|
gem 'dalli'
|
255
|
+
gem 'delayed_job'
|
256
|
+
gem 'delayed_job_active_record'
|
251
257
|
gem 'elasticsearch-transport'
|
252
258
|
gem 'excon'
|
253
259
|
gem 'hiredis'
|
@@ -379,6 +385,8 @@ elsif Gem::Version.new('2.2.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
379
385
|
gem 'activerecord', '< 5.1.5'
|
380
386
|
gem 'aws-sdk'
|
381
387
|
gem 'dalli'
|
388
|
+
gem 'delayed_job'
|
389
|
+
gem 'delayed_job_active_record'
|
382
390
|
gem 'elasticsearch-transport'
|
383
391
|
gem 'excon'
|
384
392
|
gem 'grape'
|
@@ -513,6 +521,8 @@ elsif Gem::Version.new('2.3.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
513
521
|
gem 'activerecord', '< 5.1.5'
|
514
522
|
gem 'aws-sdk'
|
515
523
|
gem 'dalli'
|
524
|
+
gem 'delayed_job'
|
525
|
+
gem 'delayed_job_active_record'
|
516
526
|
gem 'elasticsearch-transport'
|
517
527
|
gem 'excon'
|
518
528
|
gem 'grape'
|
@@ -541,6 +551,8 @@ elsif Gem::Version.new('2.4.0') <= Gem::Version.new(RUBY_VERSION)
|
|
541
551
|
gem 'activerecord', '< 5.1.5'
|
542
552
|
gem 'aws-sdk'
|
543
553
|
gem 'dalli'
|
554
|
+
gem 'delayed_job'
|
555
|
+
gem 'delayed_job_active_record'
|
544
556
|
gem 'elasticsearch-transport'
|
545
557
|
gem 'excon'
|
546
558
|
gem 'grape'
|
data/CHANGELOG.md
CHANGED
@@ -4,15 +4,27 @@
|
|
4
4
|
|
5
5
|
## [Unreleased (beta)]
|
6
6
|
|
7
|
-
## [0.
|
7
|
+
## [0.14.0.beta1] - 2018-07-24
|
8
8
|
|
9
|
-
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.
|
9
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.14.0.beta1
|
10
10
|
|
11
|
-
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.13.1...v0.
|
11
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.13.1...v0.14.0.beta1
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- Resque to flush traces when Job finishes instead of using SyncWriter (#474)
|
16
|
+
- ActiveRecord to allow configuring multiple databases (#451)
|
17
|
+
- Integrations configuration settings (#450, #452, #451)
|
12
18
|
|
13
19
|
### Fixed
|
14
20
|
|
15
|
-
|
21
|
+
- Ruby warnings during tests (#499)
|
22
|
+
- Tests failing intermittently on Ruby 1.9.3 (#497)
|
23
|
+
|
24
|
+
### Added
|
25
|
+
|
26
|
+
- DelayedJob integration (#393 #444)
|
27
|
+
- Version information to integrations (#483)
|
16
28
|
|
17
29
|
## [0.13.1] - 2018-07-17
|
18
30
|
|
@@ -390,7 +402,6 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
390
402
|
|
391
403
|
[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...master
|
392
404
|
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...0.14-dev
|
393
|
-
[0.13.2]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.1...v0.13.2
|
394
405
|
[0.13.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...v0.13.1
|
395
406
|
[0.13.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.12.1...v0.13.0
|
396
407
|
[0.13.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0...v0.13.0.beta1
|
data/Rakefile
CHANGED
@@ -39,9 +39,14 @@ namespace :spec do
|
|
39
39
|
t.pattern = 'spec/ddtrace/contrib/rails/**/*disable_env*_spec.rb'
|
40
40
|
end
|
41
41
|
|
42
|
+
RSpec::Core::RakeTask.new(:contrib) do |t|
|
43
|
+
t.pattern = 'spec/**/contrib/{configurable,integration,patchable,patcher,registerable,configuration/*}_spec.rb'
|
44
|
+
end
|
45
|
+
|
42
46
|
[
|
43
47
|
:active_model_serializers,
|
44
48
|
:active_record,
|
49
|
+
:delayed_job,
|
45
50
|
:active_support,
|
46
51
|
:aws,
|
47
52
|
:dalli,
|
@@ -144,7 +149,7 @@ end
|
|
144
149
|
|
145
150
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.1.0')
|
146
151
|
RuboCop::RakeTask.new(:rubocop) do |t|
|
147
|
-
t.options << ['-D']
|
152
|
+
t.options << ['-D', '--force-exclusion']
|
148
153
|
t.patterns = ['lib/**/*.rb', 'test/**/*.rb', 'spec/**/*.rb', 'Gemfile', 'Rakefile']
|
149
154
|
end
|
150
155
|
end
|
@@ -208,6 +213,7 @@ task :ci do
|
|
208
213
|
# Main library
|
209
214
|
sh 'bundle exec rake test:main'
|
210
215
|
sh 'bundle exec rake spec:main'
|
216
|
+
sh 'bundle exec rake spec:contrib'
|
211
217
|
|
212
218
|
if RUBY_PLATFORM != 'java'
|
213
219
|
# Contrib minitests
|
@@ -221,6 +227,7 @@ task :ci do
|
|
221
227
|
# Contrib specs
|
222
228
|
sh 'bundle exec appraisal contrib-old rake spec:active_model_serializers'
|
223
229
|
sh 'bundle exec appraisal contrib-old rake spec:active_record'
|
230
|
+
sh 'bundle exec appraisal contrib-old rake spec:delayed_job'
|
224
231
|
sh 'bundle exec appraisal contrib-old rake spec:active_support'
|
225
232
|
sh 'bundle exec appraisal contrib-old rake spec:dalli'
|
226
233
|
sh 'bundle exec appraisal contrib-old rake spec:elasticsearch'
|
@@ -250,6 +257,7 @@ task :ci do
|
|
250
257
|
# Main library
|
251
258
|
sh 'bundle exec rake test:main'
|
252
259
|
sh 'bundle exec rake spec:main'
|
260
|
+
sh 'bundle exec rake spec:contrib'
|
253
261
|
|
254
262
|
if RUBY_PLATFORM != 'java'
|
255
263
|
# Contrib minitests
|
@@ -263,6 +271,7 @@ task :ci do
|
|
263
271
|
# Contrib specs
|
264
272
|
sh 'bundle exec appraisal contrib-old rake spec:active_model_serializers'
|
265
273
|
sh 'bundle exec appraisal contrib-old rake spec:active_record'
|
274
|
+
sh 'bundle exec appraisal contrib-old rake spec:delayed_job'
|
266
275
|
sh 'bundle exec appraisal contrib-old rake spec:active_support'
|
267
276
|
sh 'bundle exec appraisal contrib-old rake spec:dalli'
|
268
277
|
sh 'bundle exec appraisal contrib-old rake spec:elasticsearch'
|
@@ -295,6 +304,7 @@ task :ci do
|
|
295
304
|
# Main library
|
296
305
|
sh 'bundle exec rake test:main'
|
297
306
|
sh 'bundle exec rake spec:main'
|
307
|
+
sh 'bundle exec rake spec:contrib'
|
298
308
|
|
299
309
|
if RUBY_PLATFORM != 'java'
|
300
310
|
# Contrib minitests
|
@@ -308,6 +318,7 @@ task :ci do
|
|
308
318
|
# Contrib specs
|
309
319
|
sh 'bundle exec appraisal contrib-old rake spec:active_model_serializers'
|
310
320
|
sh 'bundle exec appraisal contrib-old rake spec:active_record'
|
321
|
+
sh 'bundle exec appraisal contrib-old rake spec:delayed_job'
|
311
322
|
sh 'bundle exec appraisal contrib-old rake spec:active_support'
|
312
323
|
sh 'bundle exec appraisal contrib-old rake spec:dalli'
|
313
324
|
sh 'bundle exec appraisal contrib-old rake spec:elasticsearch'
|
@@ -346,6 +357,7 @@ task :ci do
|
|
346
357
|
# Main library
|
347
358
|
sh 'bundle exec rake test:main'
|
348
359
|
sh 'bundle exec rake spec:main'
|
360
|
+
sh 'bundle exec rake spec:contrib'
|
349
361
|
|
350
362
|
if RUBY_PLATFORM != 'java'
|
351
363
|
# Contrib minitests
|
@@ -359,6 +371,7 @@ task :ci do
|
|
359
371
|
# Contrib specs
|
360
372
|
sh 'bundle exec appraisal contrib rake spec:active_model_serializers'
|
361
373
|
sh 'bundle exec appraisal contrib rake spec:active_record'
|
374
|
+
sh 'bundle exec appraisal contrib rake spec:delayed_job'
|
362
375
|
sh 'bundle exec appraisal contrib rake spec:active_support'
|
363
376
|
sh 'bundle exec appraisal contrib rake spec:dalli'
|
364
377
|
sh 'bundle exec appraisal contrib rake spec:elasticsearch'
|
@@ -408,6 +421,7 @@ task :ci do
|
|
408
421
|
# Main library
|
409
422
|
sh 'bundle exec rake test:main'
|
410
423
|
sh 'bundle exec rake spec:main'
|
424
|
+
sh 'bundle exec rake spec:contrib'
|
411
425
|
|
412
426
|
if RUBY_PLATFORM != 'java'
|
413
427
|
# Contrib minitests
|
@@ -421,6 +435,7 @@ task :ci do
|
|
421
435
|
# Contrib specs
|
422
436
|
sh 'bundle exec appraisal contrib rake spec:active_model_serializers'
|
423
437
|
sh 'bundle exec appraisal contrib rake spec:active_record'
|
438
|
+
sh 'bundle exec appraisal contrib rake spec:delayed_job'
|
424
439
|
sh 'bundle exec appraisal contrib rake spec:active_support'
|
425
440
|
sh 'bundle exec appraisal contrib rake spec:dalli'
|
426
441
|
sh 'bundle exec appraisal contrib rake spec:excon'
|
@@ -469,6 +484,7 @@ task :ci do
|
|
469
484
|
# Main library
|
470
485
|
sh 'bundle exec rake test:main'
|
471
486
|
sh 'bundle exec rake spec:main'
|
487
|
+
sh 'bundle exec rake spec:contrib'
|
472
488
|
|
473
489
|
if RUBY_PLATFORM != 'java'
|
474
490
|
# Contrib minitests
|
@@ -482,6 +498,7 @@ task :ci do
|
|
482
498
|
# Contrib specs
|
483
499
|
sh 'bundle exec appraisal contrib rake spec:active_model_serializers'
|
484
500
|
sh 'bundle exec appraisal contrib rake spec:active_record'
|
501
|
+
sh 'bundle exec appraisal contrib rake spec:delayed_job'
|
485
502
|
sh 'bundle exec appraisal contrib rake spec:active_support'
|
486
503
|
sh 'bundle exec appraisal contrib rake spec:dalli'
|
487
504
|
sh 'bundle exec appraisal contrib rake spec:elasticsearch'
|
data/docs/GettingStarted.md
CHANGED
@@ -26,6 +26,7 @@ For descriptions of terminology used in APM, take a look at the [official docume
|
|
26
26
|
- [Active Record](#active-record)
|
27
27
|
- [AWS](#aws)
|
28
28
|
- [Dalli](#dalli)
|
29
|
+
- [DelayedJob](#delayedjob)
|
29
30
|
- [Elastic Search](#elastic-search)
|
30
31
|
- [Excon](#excon)
|
31
32
|
- [Faraday](#faraday)
|
@@ -163,6 +164,7 @@ And `options` is an optional `Hash` that accepts the following parameters:
|
|
163
164
|
| ``child_of`` | `Datadog::Span` / `Datadog::Context` | Parent for this span. If not provided, will automatically become current active span. | `nil` |
|
164
165
|
| ``start_time`` | `Integer` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now.utc` |
|
165
166
|
| ``tags`` | `Hash` | Extra tags which should be added to the span. | `{}` |
|
167
|
+
| ``on_error`` | `Proc` | Handler invoked when a block is provided to trace, and it raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
166
168
|
|
167
169
|
It's highly recommended you set both `service` and `resource` at a minimum. Spans without a `service` or `resource` as `nil` will be discarded by the Datadog agent.
|
168
170
|
|
@@ -258,6 +260,7 @@ For a list of available integrations, and their configuration options, please re
|
|
258
260
|
| Active Record | `active_record` | `>= 3.2, < 5.2` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
|
259
261
|
| AWS | `aws` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
|
260
262
|
| Dalli | `dalli` | `>= 2.7` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
|
263
|
+
| DelayedJob | `delayed_job` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
|
261
264
|
| Elastic Search | `elasticsearch` | `>= 6.0` | *[Link](#elastic-search)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
|
262
265
|
| Excon | `excon` | `>= 0.62` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
|
263
266
|
| Faraday | `faraday` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
|
@@ -306,6 +309,44 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
306
309
|
| ``service_name`` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `mysql2`) |
|
307
310
|
| ``orm_service_name`` | Service name used for the Ruby ORM portion of `active_record` instrumentation. Overrides service name for ORM spans if explicitly set, which otherwise inherit their service from their parent. | ``active_record`` |
|
308
311
|
|
312
|
+
**Configuring trace settings per database**
|
313
|
+
|
314
|
+
You can provide the `databases` option to configure trace settings by database connection:
|
315
|
+
|
316
|
+
```ruby
|
317
|
+
# Provide a `:describes` option with a connection key.
|
318
|
+
# Any of the following keys are acceptable, and equivalent to one another.
|
319
|
+
# If a block is provided, it yields a Settings object that
|
320
|
+
# accepts any of the configuration options listed above.
|
321
|
+
|
322
|
+
Datadog.configure do |c|
|
323
|
+
# Symbol matching your database connection in config/database.yml
|
324
|
+
# Only available if you are using Rails with ActiveRecord.
|
325
|
+
c.use :active_record, describes: :secondary_database, service_name: 'secondary-db'
|
326
|
+
|
327
|
+
c.use :active_record, describes: :secondary_database do |second_db|
|
328
|
+
second_db.service_name = 'secondary-db'
|
329
|
+
end
|
330
|
+
|
331
|
+
# Connection string with the following connection settings:
|
332
|
+
# Adapter, user, host, port, database
|
333
|
+
c.use :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
|
334
|
+
|
335
|
+
# Hash with following connection settings
|
336
|
+
# Adapter, user, host, port, database
|
337
|
+
c.use :active_record, describes: {
|
338
|
+
adapter: 'mysql2',
|
339
|
+
host: '127.0.0.1',
|
340
|
+
port: '3306',
|
341
|
+
database: 'mysql',
|
342
|
+
username: 'root'
|
343
|
+
},
|
344
|
+
service_name: 'secondary-db'
|
345
|
+
end
|
346
|
+
```
|
347
|
+
|
348
|
+
If ActiveRecord traces an event that uses a connection described within `databases`, it will use the trace settings assigned to that connection. If the connection does not match any in the `databases` option, it will use settings defined by `c.use :active_record` instead.
|
349
|
+
|
309
350
|
### AWS
|
310
351
|
|
311
352
|
The AWS integration will trace every interaction (e.g. API calls) with AWS services (S3, ElastiCache etc.).
|
@@ -792,6 +833,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
792
833
|
| ``middleware_names`` | Enables any short-circuited middleware requests to display the middleware name as resource for the trace. | `false` |
|
793
834
|
| ``template_base_path`` | Used when the template name is parsed. If you don't store your templates in the ``views/`` folder, you may need to change this value | ``views/`` |
|
794
835
|
| ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
|
836
|
+
| ``databases`` | Hash of tracer settings to use for each database connection. See [ActiveRecord](#activerecord) for more details. | ``{}`` |
|
795
837
|
|
796
838
|
### Rake
|
797
839
|
|
@@ -988,6 +1030,27 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
988
1030
|
| --- | --- | --- |
|
989
1031
|
| ``service_name`` | Service name used for `sidekiq` instrumentation | sidekiq |
|
990
1032
|
|
1033
|
+
### DelayedJob
|
1034
|
+
|
1035
|
+
The DelayedJob integration uses lifecycle hooks to trace the job executions.
|
1036
|
+
|
1037
|
+
You can enable it through `Datadog.configure`:
|
1038
|
+
|
1039
|
+
```ruby
|
1040
|
+
require 'ddtrace'
|
1041
|
+
|
1042
|
+
Datadog.configure do |c|
|
1043
|
+
c.use :delayed_job, options
|
1044
|
+
end
|
1045
|
+
```
|
1046
|
+
|
1047
|
+
Where `options` is an optional `Hash` that accepts the following parameters:
|
1048
|
+
|
1049
|
+
| Key | Description | Default |
|
1050
|
+
| --- | --- | --- |
|
1051
|
+
| ``service_name`` | Service name used for `DelayedJob` instrumentation | delayed_job |
|
1052
|
+
| ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
|
1053
|
+
|
991
1054
|
### Sinatra
|
992
1055
|
|
993
1056
|
The Sinatra integration traces requests and template rendering.
|
data/lib/ddtrace.rb
CHANGED
@@ -44,10 +44,11 @@ module Datadog
|
|
44
44
|
end
|
45
45
|
|
46
46
|
require 'ddtrace/contrib/base'
|
47
|
+
require 'ddtrace/contrib/integration'
|
47
48
|
require 'ddtrace/contrib/rack/patcher'
|
48
49
|
require 'ddtrace/contrib/rails/patcher'
|
49
50
|
require 'ddtrace/contrib/active_model_serializers/patcher'
|
50
|
-
require 'ddtrace/contrib/active_record/
|
51
|
+
require 'ddtrace/contrib/active_record/integration'
|
51
52
|
require 'ddtrace/contrib/sequel/patcher'
|
52
53
|
require 'ddtrace/contrib/elasticsearch/patcher'
|
53
54
|
require 'ddtrace/contrib/faraday/patcher'
|
@@ -62,6 +63,7 @@ require 'ddtrace/contrib/mongodb/patcher'
|
|
62
63
|
require 'ddtrace/contrib/dalli/patcher'
|
63
64
|
require 'ddtrace/contrib/rake/patcher'
|
64
65
|
require 'ddtrace/contrib/resque/patcher'
|
66
|
+
require 'ddtrace/contrib/delayed_job/patcher'
|
65
67
|
require 'ddtrace/contrib/racecar/patcher'
|
66
68
|
require 'ddtrace/contrib/sidekiq/patcher'
|
67
69
|
require 'ddtrace/contrib/excon/patcher'
|
@@ -12,16 +12,28 @@ module Datadog
|
|
12
12
|
@wrapped_registry = {}
|
13
13
|
end
|
14
14
|
|
15
|
-
def [](integration_name)
|
16
|
-
|
15
|
+
def [](integration_name, configuration_name = :default)
|
16
|
+
integration = fetch_integration(integration_name)
|
17
|
+
|
18
|
+
if integration.class <= Datadog::Contrib::Integration
|
19
|
+
integration.configuration(configuration_name)
|
20
|
+
else
|
21
|
+
@wrapped_registry[integration_name] ||= Proxy.new(integration)
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
|
-
def use(integration_name, options = {})
|
25
|
+
def use(integration_name, options = {}, &block)
|
20
26
|
integration = fetch_integration(integration_name)
|
21
|
-
settings = Proxy.new(integration)
|
22
27
|
|
23
|
-
integration.
|
24
|
-
|
28
|
+
if integration.class <= Datadog::Contrib::Integration
|
29
|
+
configuration_name = options[:describes] || :default
|
30
|
+
filtered_options = options.reject { |k, _v| k == :describes }
|
31
|
+
integration.configure(configuration_name, filtered_options, &block)
|
32
|
+
else
|
33
|
+
settings = Proxy.new(integration)
|
34
|
+
integration.sorted_options.each do |name|
|
35
|
+
settings[name] = options.fetch(name, settings[name])
|
36
|
+
end
|
25
37
|
end
|
26
38
|
|
27
39
|
integration.patch if integration.respond_to?(:patch)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'ddtrace/contrib/configuration/resolver'
|
2
|
+
require 'ddtrace/vendor/active_record/connection_specification'
|
3
|
+
|
4
|
+
module Datadog
|
5
|
+
module Contrib
|
6
|
+
module ActiveRecord
|
7
|
+
module Configuration
|
8
|
+
# Converts Symbols, Strings, and Hashes to a normalized connection settings Hash.
|
9
|
+
class Resolver < Contrib::Configuration::Resolver
|
10
|
+
def initialize(configurations = nil)
|
11
|
+
@configurations = configurations
|
12
|
+
end
|
13
|
+
|
14
|
+
def configurations
|
15
|
+
@configurations || ::ActiveRecord::Base.configurations
|
16
|
+
end
|
17
|
+
|
18
|
+
def connection_resolver
|
19
|
+
@resolver ||= begin
|
20
|
+
if defined?(::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver)
|
21
|
+
::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(configurations)
|
22
|
+
else
|
23
|
+
::Datadog::Vendor::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(configurations)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def resolve(spec)
|
29
|
+
return :default if spec == :default
|
30
|
+
normalize(connection_resolver.resolve(spec).symbolize_keys)
|
31
|
+
end
|
32
|
+
|
33
|
+
def normalize(hash)
|
34
|
+
{
|
35
|
+
adapter: hash[:adapter],
|
36
|
+
host: hash[:host],
|
37
|
+
port: hash[:port],
|
38
|
+
database: hash[:database],
|
39
|
+
username: hash[:username]
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ddtrace/contrib/configuration/settings'
|
2
|
+
require 'ddtrace/contrib/active_record/utils'
|
3
|
+
|
4
|
+
module Datadog
|
5
|
+
module Contrib
|
6
|
+
module ActiveRecord
|
7
|
+
module Configuration
|
8
|
+
# Unique settings for ActiveRecord
|
9
|
+
class Settings < Contrib::Configuration::Settings
|
10
|
+
option :orm_service_name
|
11
|
+
option :service_name, depends_on: [:tracer] do |value|
|
12
|
+
(value || Utils.adapter_name).tap do |service_name|
|
13
|
+
tracer.set_service_info(service_name, 'active_record', Ext::AppTypes::DB)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
option :tracer, default: Datadog.tracer do |value|
|
18
|
+
value.tap do
|
19
|
+
Events.subscriptions.each do |subscription|
|
20
|
+
subscription.tracer = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|