ddtrace 0.36.0 → 0.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -1
- data/.gitlab-ci.yml +26 -0
- data/CHANGELOG.md +41 -1
- data/Rakefile +22 -1
- data/ddtrace.gemspec +5 -0
- data/docs/GettingStarted.md +8 -34
- data/lib/ddtrace/configuration/pin_setup.rb +3 -2
- data/lib/ddtrace/contrib/active_support/cache/redis.rb +1 -1
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +3 -1
- data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +9 -3
- data/lib/ddtrace/contrib/configuration/settings.rb +18 -0
- data/lib/ddtrace/contrib/dalli/patcher.rb +1 -5
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +1 -2
- data/lib/ddtrace/contrib/faraday/patcher.rb +1 -5
- data/lib/ddtrace/contrib/grape/patcher.rb +1 -1
- data/lib/ddtrace/contrib/graphql/patcher.rb +6 -3
- data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +1 -1
- data/lib/ddtrace/contrib/grpc/patcher.rb +1 -5
- data/lib/ddtrace/contrib/http/instrumentation.rb +12 -7
- data/lib/ddtrace/contrib/mongodb/instrumentation.rb +1 -2
- data/lib/ddtrace/contrib/mysql2/instrumentation.rb +1 -1
- data/lib/ddtrace/contrib/patcher.rb +14 -8
- data/lib/ddtrace/contrib/rails/configuration/settings.rb +0 -12
- data/lib/ddtrace/contrib/rails/framework.rb +14 -21
- data/lib/ddtrace/contrib/redis/patcher.rb +1 -1
- data/lib/ddtrace/contrib/sequel/database.rb +1 -1
- data/lib/ddtrace/contrib/sucker_punch/patcher.rb +1 -1
- data/lib/ddtrace/pin.rb +25 -2
- data/lib/ddtrace/tracer.rb +2 -2
- data/lib/ddtrace/version.rb +1 -1
- metadata +73 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3253a2d8c0b21e8a1f37a8fdeb871fad442a7972004587ceea5a52fedb335bea
|
4
|
+
data.tar.gz: e1702aa824d9dfe47cded67df133f8bc819303260fe2254c90fa47c9ec97744a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0053d18a6ba7c003ab30d9c70fee26a300fdce9a5c996c26f1a3104b765f54877f5133e295137fb55e87681e0c10eec3c8c9b6f9bb28ea3be0d98cfc956b0dfe
|
7
|
+
data.tar.gz: 46331851889d62b9814c51ce987fcd3632a85e6ffb2f72dc69cc7e410e795a89ebb84ff3822c8e41e9a2fb07721998b30eea5249c5b72dcd6a1c237483189309
|
data/.circleci/config.yml
CHANGED
@@ -54,7 +54,9 @@ step_rubocop: &step_rubocop
|
|
54
54
|
step_appraisal_install: &step_appraisal_install
|
55
55
|
run:
|
56
56
|
name: Install Appraisal gems
|
57
|
-
command:
|
57
|
+
command: |
|
58
|
+
bundle exec appraisal clean # Ensure we fetch the latest version of dependencies
|
59
|
+
bundle exec appraisal install
|
58
60
|
step_compute_bundle_checksum: &step_compute_bundle_checksum
|
59
61
|
run:
|
60
62
|
name: Compute bundle checksum
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
stages:
|
2
|
+
- deploy
|
3
|
+
|
4
|
+
variables:
|
5
|
+
INDEX_FILE: index.txt
|
6
|
+
|
7
|
+
.common: &common
|
8
|
+
tags: [ "runner:main", "size:large" ]
|
9
|
+
|
10
|
+
copy_to_s3:
|
11
|
+
<<: *common
|
12
|
+
stage: deploy
|
13
|
+
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
|
14
|
+
rules:
|
15
|
+
- if: '$CI_COMMIT_BRANCH == "master"'
|
16
|
+
when: on_success
|
17
|
+
- when: manual
|
18
|
+
script:
|
19
|
+
- export ACCESS_KEY_ID=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-rb.secret_key_id --with-decryption --query "Parameter.Value" --out text)
|
20
|
+
- export SECRET_ACCESS_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-rb.secret_sec_key_id --with-decryption --query "Parameter.Value" --out text)
|
21
|
+
- export AWS_ACCESS_KEY_ID=$ACCESS_KEY_ID
|
22
|
+
- export AWS_SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY
|
23
|
+
- echo $CI_COMMIT_REF_NAME >> $INDEX_FILE
|
24
|
+
- echo $CI_COMMIT_SHA >> $INDEX_FILE
|
25
|
+
- echo $GITLAB_USER_NAME >> $INDEX_FILE
|
26
|
+
- aws s3 cp $INDEX_FILE s3://datadog-reliability-env/ruby/$INDEX_FILE
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,45 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [0.37.0] - 2020-06-24
|
6
|
+
|
7
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.37.0
|
8
|
+
|
9
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.36.0...v0.37.0
|
10
|
+
|
11
|
+
### Refactored
|
12
|
+
|
13
|
+
- Documentation improvements regarding Datadog Agent defaults (#1074) (@cswatt)
|
14
|
+
- Improvements to test suite (#1043, #1051, #1062, #1075, #1076, #1086)
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
|
18
|
+
- **DEPRECATION**: Deprecate Contrib::Configuration::Settings#tracer= (#1072, #1079)
|
19
|
+
- The `tracer:` option is no longer supported for integration configuration. A deprecation warning will be issued when this option is used.
|
20
|
+
- Tracer instances are dynamically created when `ddtrace` is reconfigured (through `Datadog.configure{}` calls).
|
21
|
+
|
22
|
+
A reference to a tracer instance cannot be stored as it will be replaced by a new instance during reconfiguration.
|
23
|
+
|
24
|
+
Retrieving the global tracer instance, by invoking `Datadog.tracer`, is the only safe mechanism to acquire the active tracer instance.
|
25
|
+
|
26
|
+
Allowing an integration to set its tracer instance is effectively preventing that integration from dynamically retrieving the current active tracer in the future, thus causing it to record spans in a stale tracer instance. Spans recorded in a stale tracer instance will look disconnected from their parent context.
|
27
|
+
|
28
|
+
- **BREAKING**: Remove Pin#tracer= and DeprecatedPin#tracer= (#1073)
|
29
|
+
- The `Pin` and `DeprecatedPin` are internal tools used to provide more granular configuration for integrations.
|
30
|
+
- The APIs being removed are not public nor have been externally documented. The `DeprecatedPin` specifically has been considered deprecated since 0.20.0.
|
31
|
+
- This removal is a continuation of #1079 above, thus carrying the same rationale.
|
32
|
+
|
33
|
+
### Migration
|
34
|
+
|
35
|
+
- Remove `tracer` argument provided to integrations (e.g. `c.use :rails, tracer: ...`).
|
36
|
+
- Remove `tracer` argument provided to `Pin` or `DeprecatedPin` initializers (e.g. `Pin.new(service, tracer: ...)`).
|
37
|
+
- If you require a custom tracer instance, use a global instance configuration:
|
38
|
+
```ruby
|
39
|
+
Datadog.configure do |c|
|
40
|
+
c.tracer.instance = custom_tracer
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
5
44
|
## [0.36.0] - 2020-05-27
|
6
45
|
|
7
46
|
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.36.0
|
@@ -1235,7 +1274,8 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
|
|
1235
1274
|
|
1236
1275
|
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
1237
1276
|
|
1238
|
-
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v0.
|
1277
|
+
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v0.37.0...master
|
1278
|
+
[0.37.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.36.0...v0.37.0
|
1239
1279
|
[0.36.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.35.2...v0.36.0
|
1240
1280
|
[0.35.2]: https://github.com/DataDog/dd-trace-rb/compare/v0.35.1...v0.35.2
|
1241
1281
|
[0.35.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.35.0...v0.35.1
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ Dir.glob('tasks/*.rake').each { |r| import r }
|
|
11
11
|
desc 'Run RSpec'
|
12
12
|
# rubocop:disable Metrics/BlockLength
|
13
13
|
namespace :spec do
|
14
|
-
task all: [:main,
|
14
|
+
task all: [:main, :benchmark,
|
15
15
|
:rails, :railsredis, :railsactivejob,
|
16
16
|
:elasticsearch, :http, :redis, :sidekiq, :sinatra]
|
17
17
|
|
@@ -21,6 +21,11 @@ namespace :spec do
|
|
21
21
|
t.rspec_opts = args.to_a.join(' ')
|
22
22
|
end
|
23
23
|
|
24
|
+
RSpec::Core::RakeTask.new(:benchmark) do |t, args|
|
25
|
+
t.pattern = 'spec/ddtrace/benchmark/**/*_spec.rb'
|
26
|
+
t.rspec_opts = args.to_a.join(' ')
|
27
|
+
end
|
28
|
+
|
24
29
|
RSpec::Core::RakeTask.new(:opentracer) do |t, args|
|
25
30
|
t.pattern = 'spec/ddtrace/opentracer/**/*_spec.rb'
|
26
31
|
t.rspec_opts = args.to_a.join(' ')
|
@@ -188,6 +193,8 @@ task :ci do
|
|
188
193
|
sh 'bundle exec rake test:main'
|
189
194
|
sh 'bundle exec rake spec:main'
|
190
195
|
sh 'bundle exec rake spec:contrib'
|
196
|
+
# Benchmarks
|
197
|
+
sh 'bundle exec rake spec:benchmark'
|
191
198
|
|
192
199
|
if RUBY_PLATFORM != 'java'
|
193
200
|
# Contrib minitests
|
@@ -243,6 +250,8 @@ task :ci do
|
|
243
250
|
sh 'bundle exec rake spec:main'
|
244
251
|
sh 'bundle exec rake spec:contrib'
|
245
252
|
sh 'bundle exec rake spec:opentracer'
|
253
|
+
# Benchmarks
|
254
|
+
sh 'bundle exec rake spec:benchmark'
|
246
255
|
|
247
256
|
if RUBY_PLATFORM != 'java'
|
248
257
|
# Contrib minitests
|
@@ -305,6 +314,8 @@ task :ci do
|
|
305
314
|
sh 'bundle exec rake spec:main'
|
306
315
|
sh 'bundle exec rake spec:contrib'
|
307
316
|
sh 'bundle exec rake spec:opentracer'
|
317
|
+
# Benchmarks
|
318
|
+
sh 'bundle exec rake spec:benchmark'
|
308
319
|
|
309
320
|
if RUBY_PLATFORM != 'java'
|
310
321
|
# Contrib minitests
|
@@ -378,6 +389,8 @@ task :ci do
|
|
378
389
|
sh 'bundle exec rake spec:main'
|
379
390
|
sh 'bundle exec rake spec:contrib'
|
380
391
|
sh 'bundle exec rake spec:opentracer'
|
392
|
+
# Benchmarks
|
393
|
+
sh 'bundle exec rake spec:benchmark'
|
381
394
|
|
382
395
|
if RUBY_PLATFORM != 'java'
|
383
396
|
# Contrib minitests
|
@@ -454,6 +467,8 @@ task :ci do
|
|
454
467
|
sh 'bundle exec rake spec:contrib'
|
455
468
|
sh 'bundle exec rake spec:opentracer'
|
456
469
|
sh 'bundle exec rake spec:opentelemetry'
|
470
|
+
# Benchmarks
|
471
|
+
sh 'bundle exec rake spec:benchmark'
|
457
472
|
|
458
473
|
if RUBY_PLATFORM != 'java'
|
459
474
|
# Benchmarks
|
@@ -517,6 +532,8 @@ task :ci do
|
|
517
532
|
sh 'bundle exec rake spec:contrib'
|
518
533
|
sh 'bundle exec rake spec:opentracer'
|
519
534
|
sh 'bundle exec rake spec:opentelemetry'
|
535
|
+
# Benchmarks
|
536
|
+
sh 'bundle exec rake spec:benchmark'
|
520
537
|
|
521
538
|
if RUBY_PLATFORM != 'java'
|
522
539
|
# Benchmarks
|
@@ -590,6 +607,8 @@ task :ci do
|
|
590
607
|
sh 'bundle exec rake spec:contrib'
|
591
608
|
sh 'bundle exec rake spec:opentracer'
|
592
609
|
sh 'bundle exec rake spec:opentelemetry'
|
610
|
+
# Benchmarks
|
611
|
+
sh 'bundle exec rake spec:benchmark'
|
593
612
|
|
594
613
|
if RUBY_PLATFORM != 'java'
|
595
614
|
# Benchmarks
|
@@ -662,6 +681,8 @@ task :ci do
|
|
662
681
|
sh 'bundle exec rake spec:contrib'
|
663
682
|
sh 'bundle exec rake spec:opentracer'
|
664
683
|
sh 'bundle exec rake spec:opentelemetry'
|
684
|
+
# Benchmarks
|
685
|
+
sh 'bundle exec rake spec:benchmark'
|
665
686
|
|
666
687
|
if RUBY_PLATFORM != 'java'
|
667
688
|
# Benchmarks
|
data/ddtrace.gemspec
CHANGED
@@ -46,6 +46,8 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
47
47
|
spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
|
48
48
|
spec.add_development_dependency 'minitest', '= 5.10.1'
|
49
|
+
spec.add_development_dependency 'minitest-around', '0.5.0'
|
50
|
+
spec.add_development_dependency 'minitest-stub_any_instance', '1.0.2'
|
49
51
|
spec.add_development_dependency 'appraisal', '~> 2.2'
|
50
52
|
spec.add_development_dependency 'yard', '~> 0.9'
|
51
53
|
spec.add_development_dependency 'webmock', '~> 2.0'
|
@@ -59,6 +61,9 @@ Gem::Specification.new do |spec|
|
|
59
61
|
|
60
62
|
# locking transitive dependency of webmock
|
61
63
|
spec.add_development_dependency 'addressable', '~> 2.4.0'
|
64
|
+
spec.add_development_dependency 'benchmark-ips', '~> 2.8'
|
65
|
+
spec.add_development_dependency 'benchmark-memory', '~> 0.1'
|
66
|
+
spec.add_development_dependency 'memory_profiler', '~> 0.9'
|
62
67
|
spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
|
63
68
|
spec.add_development_dependency 'pry', '~> 0.10.4'
|
64
69
|
spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9.2'
|
data/docs/GettingStarted.md
CHANGED
@@ -381,7 +381,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
381
381
|
| --- | ----------- | ------- |
|
382
382
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
383
383
|
| `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
|
384
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
385
384
|
|
386
385
|
### Action View
|
387
386
|
|
@@ -402,7 +401,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
402
401
|
| ---| --- | --- |
|
403
402
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
404
403
|
| `service_name` | Service name used for rendering instrumentation. | `action_view` |
|
405
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
406
404
|
| `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/'` |
|
407
405
|
|
408
406
|
### Active Model Serializers
|
@@ -425,7 +423,6 @@ ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
|
|
425
423
|
| --- | ----------- | ------- |
|
426
424
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
427
425
|
| `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
|
428
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
429
426
|
|
430
427
|
### Action Pack
|
431
428
|
|
@@ -446,7 +443,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
446
443
|
| ---| --- | --- |
|
447
444
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
448
445
|
| `service_name` | Service name used for rendering instrumentation. | `action_pack` |
|
449
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
450
446
|
|
451
447
|
### Active Record
|
452
448
|
|
@@ -476,7 +472,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
476
472
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
|
477
473
|
| `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'` |
|
478
474
|
| `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
|
479
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
|
480
475
|
|
481
476
|
**Configuring trace settings per database**
|
482
477
|
|
@@ -538,7 +533,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
538
533
|
| ---| --- | --- |
|
539
534
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
540
535
|
| `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
|
541
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
542
536
|
|
543
537
|
### AWS
|
544
538
|
|
@@ -562,7 +556,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
562
556
|
| --- | ----------- | ------- |
|
563
557
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
564
558
|
| `service_name` | Service name used for `aws` instrumentation | `'aws'` |
|
565
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
566
559
|
|
567
560
|
### Concurrent Ruby
|
568
561
|
|
@@ -589,7 +582,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
589
582
|
| Key | Description | Default |
|
590
583
|
| --- | ----------- | ------- |
|
591
584
|
| `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
|
592
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
593
585
|
|
594
586
|
### Dalli
|
595
587
|
|
@@ -615,7 +607,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
615
607
|
| --- | ----------- | ------- |
|
616
608
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
617
609
|
| `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
|
618
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
619
610
|
|
620
611
|
### DelayedJob
|
621
612
|
|
@@ -637,7 +628,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
637
628
|
| --- | ----------- | ------- |
|
638
629
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
639
630
|
| `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
|
640
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
641
631
|
|
642
632
|
### Elasticsearch
|
643
633
|
|
@@ -663,7 +653,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
663
653
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
664
654
|
| `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{}` |
|
665
655
|
| `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
|
666
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
667
656
|
|
668
657
|
### Ethon
|
669
658
|
|
@@ -691,7 +680,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
691
680
|
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
692
681
|
| `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
|
693
682
|
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
694
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
695
683
|
|
696
684
|
### Excon
|
697
685
|
|
@@ -725,7 +713,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
725
713
|
| `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
|
726
714
|
| `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
|
727
715
|
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
728
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
729
716
|
|
730
717
|
**Configuring connections to use different settings**
|
731
718
|
|
@@ -789,7 +776,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
789
776
|
| `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
|
790
777
|
| `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
|
791
778
|
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
792
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
|
793
779
|
|
794
780
|
### Grape
|
795
781
|
|
@@ -822,7 +808,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
822
808
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
|
823
809
|
| `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
824
810
|
| `service_name` | Service name used for `grape` instrumentation | `'grape'` |
|
825
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
826
811
|
|
827
812
|
### GraphQL
|
828
813
|
|
@@ -847,7 +832,6 @@ The `use :graphql` method accepts the following parameters. Additional options c
|
|
847
832
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
|
848
833
|
| `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
|
849
834
|
| `schemas` | Required. Array of `GraphQL::Schema` objects which to trace. Tracing will be added to all the schemas listed, using the options provided to this configuration. If you do not provide any, then tracing will not be activated. | `[]` |
|
850
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
851
835
|
|
852
836
|
**Manually configuring GraphQL schemas**
|
853
837
|
|
@@ -926,7 +910,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
926
910
|
| --- | ----------- | ------- |
|
927
911
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
928
912
|
| `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
|
929
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
930
913
|
|
931
914
|
**Configuring clients to use different settings**
|
932
915
|
|
@@ -974,7 +957,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
974
957
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
975
958
|
| `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{ show: [:collection, :database, :operation] }` |
|
976
959
|
| `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
|
977
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
978
960
|
|
979
961
|
### MySQL2
|
980
962
|
|
@@ -998,7 +980,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
998
980
|
| --- | ----------- | ------- |
|
999
981
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1000
982
|
| `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
|
1001
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1002
983
|
|
1003
984
|
### Net/HTTP
|
1004
985
|
|
@@ -1034,7 +1015,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1034
1015
|
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1035
1016
|
| `service_name` | Service name used for `http` instrumentation | `'net/http'` |
|
1036
1017
|
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1037
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1038
1018
|
|
1039
1019
|
If you wish to configure each connection object individually, you may use the `Datadog.configure` as it follows:
|
1040
1020
|
|
@@ -1074,7 +1054,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1074
1054
|
| --- | ----------- | ------- |
|
1075
1055
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1076
1056
|
| `service_name` | Service name used for `presto` instrumentation | `'presto'` |
|
1077
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1078
1057
|
|
1079
1058
|
### Racecar
|
1080
1059
|
|
@@ -1096,7 +1075,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1096
1075
|
| --- | ----------- | ------- |
|
1097
1076
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1098
1077
|
| `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
|
1099
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1100
1078
|
|
1101
1079
|
### Rack
|
1102
1080
|
|
@@ -1137,7 +1115,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1137
1115
|
| `quantize.fragment` | Defines behavior for URL fragments. Removes fragments by default. May be `:show` to show URL fragments. Option must be nested inside the `quantize` option. | `nil` |
|
1138
1116
|
| `request_queuing` | Track HTTP request time spent in the queue of the frontend server. See [HTTP request queuing](#http-request-queuing) for setup details. Set to `true` to enable. | `false` |
|
1139
1117
|
| `service_name` | Service name used for `rack` instrumentation | `'rack'` |
|
1140
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1141
1118
|
| `web_service_name` | Service name for frontend server request queuing spans. (e.g. `'nginx'`) | `'web-server'` |
|
1142
1119
|
|
1143
1120
|
|
@@ -1200,7 +1177,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1200
1177
|
| `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
|
1201
1178
|
| `service_name` | Service name used when tracing application requests (on the `rack` level) | `'<app_name>'` (inferred from your Rails application namespace) |
|
1202
1179
|
| `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/'` |
|
1203
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
|
1204
1180
|
|
1205
1181
|
**Supported versions**
|
1206
1182
|
|
@@ -1243,7 +1219,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1243
1219
|
| `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1244
1220
|
| `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
|
1245
1221
|
| `service_name` | Service name used for `rake` instrumentation | `'rake'` |
|
1246
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
|
1247
1222
|
|
1248
1223
|
**Configuring task quantization behavior**
|
1249
1224
|
|
@@ -1302,11 +1277,17 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1302
1277
|
| --- | ----------- | ------- |
|
1303
1278
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1304
1279
|
| `service_name` | Service name used for `redis` instrumentation | `'redis'` |
|
1305
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1306
1280
|
|
1307
1281
|
You can also set *per-instance* configuration as it follows:
|
1308
1282
|
|
1309
1283
|
```ruby
|
1284
|
+
require 'redis'
|
1285
|
+
require 'ddtrace'
|
1286
|
+
|
1287
|
+
Datadog.configure do |c|
|
1288
|
+
c.use :redis # Enabling integration instrumentation is still required
|
1289
|
+
end
|
1290
|
+
|
1310
1291
|
customer_cache = Redis.new
|
1311
1292
|
invoice_cache = Redis.new
|
1312
1293
|
|
@@ -1372,7 +1353,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1372
1353
|
| --- | ----------- | ------- |
|
1373
1354
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
|
1374
1355
|
| `service_name` | Service name used for `resque` instrumentation | `'resque'` |
|
1375
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
|
1376
1356
|
| `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
|
1377
1357
|
|
1378
1358
|
### Rest Client
|
@@ -1395,7 +1375,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1395
1375
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1396
1376
|
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1397
1377
|
| `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
|
1398
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1399
1378
|
|
1400
1379
|
### Sequel
|
1401
1380
|
|
@@ -1429,7 +1408,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1429
1408
|
| --- | ----------- | ------- |
|
1430
1409
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1431
1410
|
| `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
|
1432
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1433
1411
|
|
1434
1412
|
Only Ruby 2.0+ is supported.
|
1435
1413
|
|
@@ -1466,7 +1444,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1466
1444
|
| --- | ----------- | ------- |
|
1467
1445
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1468
1446
|
| `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
|
1469
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1470
1447
|
|
1471
1448
|
### Sidekiq
|
1472
1449
|
|
@@ -1490,7 +1467,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1490
1467
|
| `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
|
1491
1468
|
| `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
|
1492
1469
|
| `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
|
1493
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1494
1470
|
|
1495
1471
|
### Sinatra
|
1496
1472
|
|
@@ -1555,7 +1531,6 @@ Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before y
|
|
1555
1531
|
| `headers` | Hash of HTTP request or response headers to add as tags to the `sinatra.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
|
1556
1532
|
| `resource_script_names` | Prepend resource names with script name | `false` |
|
1557
1533
|
| `service_name` | Service name used for `sinatra` instrumentation | `'sinatra'` |
|
1558
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1559
1534
|
|
1560
1535
|
### Sucker Punch
|
1561
1536
|
|
@@ -1578,7 +1553,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1578
1553
|
| --- | ----------- | ------- |
|
1579
1554
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1580
1555
|
| `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
|
1581
|
-
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
|
1582
1556
|
|
1583
1557
|
## Advanced configuration
|
1584
1558
|
|
@@ -1809,7 +1783,7 @@ Service C:
|
|
1809
1783
|
|
1810
1784
|
**Activating distributed tracing for integrations**
|
1811
1785
|
|
1812
|
-
Many integrations included in `ddtrace` support distributed tracing. Distributed tracing is enabled by default,
|
1786
|
+
Many integrations included in `ddtrace` support distributed tracing. Distributed tracing is enabled by default in Agent v7 and most versions of Agent v6. If needed, you can activate distributed tracing with configuration settings.
|
1813
1787
|
|
1814
1788
|
- If your application receives requests from services with distributed tracing activated, you must activate distributed tracing on the integrations that handle these requests (e.g. Rails)
|
1815
1789
|
- If your application send requests to services with distributed tracing activated, you must activate distributed tracing on the integrations that send these requests (e.g. Faraday)
|
@@ -13,7 +13,7 @@ module Datadog
|
|
13
13
|
|
14
14
|
ATTRS.each { |key| pin.public_send("#{key}=", opts[key]) if opts[key] }
|
15
15
|
|
16
|
-
pin.config = opts.reject { |key, _| ATTRS.include?(key) }
|
16
|
+
pin.config = opts.reject { |key, _| ATTRS.include?(key) || DEPRECATED_ATTRS.include?(key) }
|
17
17
|
|
18
18
|
true
|
19
19
|
end
|
@@ -22,7 +22,8 @@ module Datadog
|
|
22
22
|
|
23
23
|
attr_reader :pin, :opts
|
24
24
|
|
25
|
-
ATTRS = [:app, :tags, :app_type, :name, :
|
25
|
+
ATTRS = [:app, :tags, :app_type, :name, :service_name].freeze
|
26
|
+
DEPRECATED_ATTRS = [:tracer].freeze
|
26
27
|
|
27
28
|
private_constant :ATTRS
|
28
29
|
end
|
@@ -14,7 +14,7 @@ module Datadog
|
|
14
14
|
# We need to do a per-method monkey patching as some of them might
|
15
15
|
# be redefined, and some of them not. The latest version of redis-activesupport
|
16
16
|
# redefines write but leaves untouched read and delete:
|
17
|
-
# https://github.com/redis-store/redis-activesupport/blob/
|
17
|
+
# https://github.com/redis-store/redis-activesupport/blob/v4.1.5/lib/active_support/cache/redis_store.rb
|
18
18
|
#
|
19
19
|
# For Rails >= 5.2 w/o redis-activesupport...
|
20
20
|
# ActiveSupport includes a Redis cache store internally, and does not require these overrides.
|
@@ -18,6 +18,8 @@ module Datadog
|
|
18
18
|
# Redefines some class behaviors for a Subscriber to make
|
19
19
|
# it a bit simpler for an Event.
|
20
20
|
module ClassMethods
|
21
|
+
DEFAULT_TRACER = -> { Datadog.tracer }
|
22
|
+
|
21
23
|
def subscribe!
|
22
24
|
super
|
23
25
|
end
|
@@ -52,7 +54,7 @@ module Datadog
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def tracer
|
55
|
-
|
57
|
+
DEFAULT_TRACER
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
@@ -16,11 +16,17 @@ module Datadog
|
|
16
16
|
|
17
17
|
# post method runs the task within composited executor - in a different thread
|
18
18
|
def post(*args, &task)
|
19
|
-
|
19
|
+
parent_context = datadog_configuration.tracer.provider.context
|
20
20
|
|
21
21
|
@composited_executor.post(*args) do
|
22
|
-
|
23
|
-
|
22
|
+
begin
|
23
|
+
original_context = datadog_configuration.tracer.provider.context
|
24
|
+
datadog_configuration.tracer.provider.context = parent_context
|
25
|
+
yield
|
26
|
+
ensure
|
27
|
+
# Restore context in case the current thread gets reused
|
28
|
+
datadog_configuration.tracer.provider.context = original_context
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
@@ -12,6 +12,9 @@ module Datadog
|
|
12
12
|
option :service_name
|
13
13
|
option :tracer do |o|
|
14
14
|
o.delegate_to { Datadog.tracer }
|
15
|
+
o.on_set do |_value|
|
16
|
+
log_deprecation_warning(:tracer)
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
def configure(options = {})
|
@@ -29,6 +32,21 @@ module Datadog
|
|
29
32
|
def []=(name, value)
|
30
33
|
respond_to?("#{name}=") ? send("#{name}=", value) : set_option(name, value)
|
31
34
|
end
|
35
|
+
|
36
|
+
DEPRECATION_WARNING = %(
|
37
|
+
Explicitly providing a tracer instance is DEPRECATED.
|
38
|
+
It's recommended to not provide an explicit tracer instance
|
39
|
+
and let Datadog::Contrib::Configuration::Settings resolve
|
40
|
+
the correct tracer internally.
|
41
|
+
).freeze
|
42
|
+
|
43
|
+
include Datadog::Patcher # DEV includes #do_once here. We should move that logic to a generic component.
|
44
|
+
|
45
|
+
def log_deprecation_warning(method_name)
|
46
|
+
do_once(method_name) do
|
47
|
+
Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}:#{caller.join("\n")}")
|
48
|
+
end
|
49
|
+
end
|
32
50
|
end
|
33
51
|
end
|
34
52
|
end
|
@@ -29,7 +29,7 @@ module Datadog
|
|
29
29
|
get_option(:service_name),
|
30
30
|
app: Ext::APP,
|
31
31
|
app_type: Datadog::Ext::AppTypes::CACHE,
|
32
|
-
tracer: get_option(:tracer)
|
32
|
+
tracer: -> { get_option(:tracer) }
|
33
33
|
).onto(::Dalli)
|
34
34
|
end
|
35
35
|
|
@@ -47,10 +47,6 @@ module Datadog
|
|
47
47
|
Upgrade to the configuration API using the migration guide here:
|
48
48
|
https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0).freeze
|
49
49
|
|
50
|
-
def tracer=(tracer)
|
51
|
-
Datadog.configuration[:dalli][:tracer] = tracer
|
52
|
-
end
|
53
|
-
|
54
50
|
def service_name=(service_name)
|
55
51
|
Datadog.configuration[:dalli][:service_name] = service_name
|
56
52
|
end
|
@@ -37,14 +37,13 @@ module Datadog
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def initialize(*args, &block)
|
40
|
-
tracer = Datadog.configuration[:elasticsearch][:tracer]
|
41
40
|
service = Datadog.configuration[:elasticsearch][:service_name]
|
42
41
|
|
43
42
|
pin = Datadog::Pin.new(
|
44
43
|
service,
|
45
44
|
app: Datadog::Contrib::Elasticsearch::Ext::APP,
|
46
45
|
app_type: Datadog::Ext::AppTypes::DB,
|
47
|
-
tracer: tracer
|
46
|
+
tracer: -> { Datadog.configuration[:elasticsearch][:tracer] }
|
48
47
|
)
|
49
48
|
pin.onto(self)
|
50
49
|
initialize_without_datadog(*args, &block)
|
@@ -31,7 +31,7 @@ module Datadog
|
|
31
31
|
get_option(:service_name),
|
32
32
|
app: Ext::APP,
|
33
33
|
app_type: Datadog::Ext::AppTypes::WEB,
|
34
|
-
tracer: get_option(:tracer)
|
34
|
+
tracer: -> { get_option(:tracer) }
|
35
35
|
).onto(::Faraday)
|
36
36
|
end
|
37
37
|
|
@@ -61,10 +61,6 @@ module Datadog
|
|
61
61
|
Upgrade to the configuration API using the migration guide here:
|
62
62
|
https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0).freeze
|
63
63
|
|
64
|
-
def tracer=(tracer)
|
65
|
-
Datadog.configuration[:faraday][:tracer] = tracer
|
66
|
-
end
|
67
|
-
|
68
64
|
def service_name=(service_name)
|
69
65
|
Datadog.configuration[:faraday][:service_name] = service_name
|
70
66
|
end
|
@@ -22,7 +22,6 @@ module Datadog
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def patch_schema!(schema)
|
25
|
-
tracer = get_option(:tracer)
|
26
25
|
service_name = get_option(:service_name)
|
27
26
|
analytics_enabled = Contrib::Analytics.enabled?(get_option(:analytics_enabled))
|
28
27
|
analytics_sample_rate = get_option(:analytics_sample_rate)
|
@@ -30,7 +29,9 @@ module Datadog
|
|
30
29
|
if schema.respond_to?(:use)
|
31
30
|
schema.use(
|
32
31
|
::GraphQL::Tracing::DataDogTracing,
|
33
|
-
tracer
|
32
|
+
# By default, Tracing::DataDogTracing indirectly delegates the tracer instance
|
33
|
+
# to +Datadog.tracer+. If we provide a tracer argument here it will be eagerly cached,
|
34
|
+
# and Tracing::DataDogTracing will send traces to a stale tracer instance.
|
34
35
|
service: service_name,
|
35
36
|
analytics_enabled: analytics_enabled,
|
36
37
|
analytics_sample_rate: analytics_sample_rate
|
@@ -39,7 +40,9 @@ module Datadog
|
|
39
40
|
schema.define do
|
40
41
|
use(
|
41
42
|
::GraphQL::Tracing::DataDogTracing,
|
42
|
-
tracer
|
43
|
+
# By default, Tracing::DataDogTracing indirectly delegates the tracer instance
|
44
|
+
# to +Datadog.tracer+. If we provide a tracer argument here it will be eagerly cached,
|
45
|
+
# and Tracing::DataDogTracing will send traces to a stale tracer instance.
|
43
46
|
service: service_name,
|
44
47
|
analytics_enabled: analytics_enabled,
|
45
48
|
analytics_sample_rate: analytics_sample_rate
|
@@ -29,7 +29,7 @@ module Datadog
|
|
29
29
|
get_option(:service_name),
|
30
30
|
app: Ext::APP,
|
31
31
|
app_type: Datadog::Ext::AppTypes::WEB,
|
32
|
-
tracer: get_option(:tracer)
|
32
|
+
tracer: -> { get_option(:tracer) }
|
33
33
|
).onto(::GRPC)
|
34
34
|
end
|
35
35
|
|
@@ -52,10 +52,6 @@ module Datadog
|
|
52
52
|
Upgrade to the configuration API using the migration guide here:
|
53
53
|
https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0).freeze
|
54
54
|
|
55
|
-
def tracer=(tracer)
|
56
|
-
Datadog.configuration[:grpc][:tracer] = tracer
|
57
|
-
end
|
58
|
-
|
59
55
|
def service_name=(service_name)
|
60
56
|
Datadog.configuration[:grpc][:service_name] = service_name
|
61
57
|
end
|
@@ -111,9 +111,12 @@ module Datadog
|
|
111
111
|
service = config[:service_name]
|
112
112
|
tracer = config[:tracer]
|
113
113
|
|
114
|
-
@datadog_pin ||=
|
115
|
-
|
116
|
-
|
114
|
+
@datadog_pin ||= Datadog::Pin.new(
|
115
|
+
service,
|
116
|
+
app: Ext::APP,
|
117
|
+
app_type: Datadog::Ext::AppTypes::WEB,
|
118
|
+
tracer: -> { config[:tracer] }
|
119
|
+
)
|
117
120
|
|
118
121
|
# this shockingly poor code exists to solve the case where someone
|
119
122
|
# calls datadog_pin on this object before running a request, which
|
@@ -136,10 +139,12 @@ module Datadog
|
|
136
139
|
def default_datadog_pin
|
137
140
|
config = Datadog.configuration[:http]
|
138
141
|
service = config[:service_name]
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
142
|
+
@default_datadog_pin ||= Datadog::Pin.new(
|
143
|
+
service,
|
144
|
+
app: Ext::APP,
|
145
|
+
app_type: Datadog::Ext::AppTypes::WEB,
|
146
|
+
tracer: -> { config[:tracer] }
|
147
|
+
)
|
143
148
|
end
|
144
149
|
|
145
150
|
private
|
@@ -49,14 +49,13 @@ module Datadog
|
|
49
49
|
module InstanceMethods
|
50
50
|
def datadog_pin
|
51
51
|
@datadog_pin ||= begin
|
52
|
-
tracer = Datadog.configuration[:mongo][:tracer]
|
53
52
|
service = Datadog.configuration[:mongo][:service_name]
|
54
53
|
|
55
54
|
Datadog::Pin.new(
|
56
55
|
service,
|
57
56
|
app: Datadog::Contrib::MongoDB::Ext::APP,
|
58
57
|
app_type: Datadog::Ext::AppTypes::DB,
|
59
|
-
tracer: tracer
|
58
|
+
tracer: -> { Datadog.configuration[:mongo][:tracer] }
|
60
59
|
)
|
61
60
|
end
|
62
61
|
end
|
@@ -31,18 +31,24 @@ module Datadog
|
|
31
31
|
Datadog.health_metrics.instrumentation_patched(1, tags: default_tags)
|
32
32
|
end
|
33
33
|
rescue StandardError => e
|
34
|
-
|
35
|
-
Datadog.logger.error("Failed to apply #{patch_name} patch. Cause: #{e} Location: #{e.backtrace.first}")
|
36
|
-
|
37
|
-
# Emit a metric
|
38
|
-
tags = default_tags
|
39
|
-
tags << "error:#{e.class.name}"
|
40
|
-
|
41
|
-
Datadog.health_metrics.error_instrumentation_patch(1, tags: tags)
|
34
|
+
on_patch_error(e)
|
42
35
|
end
|
43
36
|
end
|
44
37
|
end
|
45
38
|
|
39
|
+
# Processes patching errors. This default implementation logs the error and reports relevant metrics.
|
40
|
+
# @param e [Exception]
|
41
|
+
def on_patch_error(e)
|
42
|
+
# Log the error
|
43
|
+
Datadog.logger.error("Failed to apply #{patch_name} patch. Cause: #{e} Location: #{e.backtrace.first}")
|
44
|
+
|
45
|
+
# Emit a metric
|
46
|
+
tags = default_tags
|
47
|
+
tags << "error:#{e.class.name}"
|
48
|
+
|
49
|
+
Datadog.health_metrics.error_instrumentation_patch(1, tags: tags)
|
50
|
+
end
|
51
|
+
|
46
52
|
private
|
47
53
|
|
48
54
|
def default_tags
|
@@ -76,18 +76,6 @@ module Datadog
|
|
76
76
|
Datadog.configuration[:action_view][:template_base_path] = value
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
|
-
option :tracer do |o|
|
81
|
-
o.delegate_to { Datadog.tracer }
|
82
|
-
o.on_set do |value|
|
83
|
-
Datadog.configuration[:action_cable][:tracer] = value
|
84
|
-
Datadog.configuration[:active_record][:tracer] = value
|
85
|
-
Datadog.configuration[:active_support][:tracer] = value
|
86
|
-
Datadog.configuration[:action_pack][:tracer] = value
|
87
|
-
Datadog.configuration[:action_view][:tracer] = value
|
88
|
-
Datadog.configuration[:rack][:tracer] = value
|
89
|
-
end
|
90
|
-
end
|
91
79
|
end
|
92
80
|
end
|
93
81
|
end
|
@@ -19,10 +19,12 @@ module Datadog
|
|
19
19
|
# - handle configuration entries which are specific to Datadog tracing
|
20
20
|
# - instrument parts of the framework when needed
|
21
21
|
module Framework
|
22
|
-
# configure
|
22
|
+
# After the Rails application finishes initializing, we configure the Rails
|
23
|
+
# integration and all its sub-components with the application information
|
24
|
+
# available.
|
25
|
+
# We do this after the initialization because not all the information we
|
26
|
+
# require is available before then.
|
23
27
|
def self.setup
|
24
|
-
rails_config = config_with_defaults
|
25
|
-
|
26
28
|
# NOTE: #configure has the side effect of rebuilding trace components.
|
27
29
|
# During a typical Rails application lifecycle, we will see trace
|
28
30
|
# components initialized twice because of this. This is necessary
|
@@ -31,6 +33,8 @@ module Datadog
|
|
31
33
|
# used to reconfigure tracer components with Rails-sourced defaults.
|
32
34
|
# This is a trade-off we take to get nice defaults.
|
33
35
|
Datadog.configure do |datadog_config|
|
36
|
+
rails_config = config_with_defaults(datadog_config)
|
37
|
+
|
34
38
|
# By default, default service would be guessed from the script
|
35
39
|
# being executed, but here we know better, get it from Rails config.
|
36
40
|
# Don't set this if service has been explicitly provided by the user.
|
@@ -43,17 +47,12 @@ module Datadog
|
|
43
47
|
activate_action_view!(datadog_config, rails_config)
|
44
48
|
activate_active_record!(datadog_config, rails_config)
|
45
49
|
end
|
46
|
-
|
47
|
-
# Update the tracer if its not the default tracer.
|
48
|
-
if rails_config[:tracer] != Datadog.configuration.tracer
|
49
|
-
rails_config[:tracer].default_service = rails_config[:service_name]
|
50
|
-
end
|
51
50
|
end
|
52
51
|
|
53
|
-
def self.config_with_defaults
|
52
|
+
def self.config_with_defaults(datadog_config)
|
54
53
|
# We set defaults here instead of in the patcher because we need to wait
|
55
54
|
# for the Rails application to be fully initialized.
|
56
|
-
|
55
|
+
datadog_config[:rails].tap do |config|
|
57
56
|
config[:service_name] ||= (Datadog.configuration.service || Utils.app_name)
|
58
57
|
config[:database_service] ||= "#{config[:service_name]}-#{Contrib::ActiveRecord::Utils.adapter_name}"
|
59
58
|
config[:controller_service] ||= config[:service_name]
|
@@ -64,7 +63,6 @@ module Datadog
|
|
64
63
|
def self.activate_rack!(datadog_config, rails_config)
|
65
64
|
datadog_config.use(
|
66
65
|
:rack,
|
67
|
-
tracer: rails_config[:tracer],
|
68
66
|
application: ::Rails.application,
|
69
67
|
service_name: rails_config[:service_name],
|
70
68
|
middleware_names: rails_config[:middleware_names],
|
@@ -77,8 +75,7 @@ module Datadog
|
|
77
75
|
|
78
76
|
datadog_config.use(
|
79
77
|
:active_support,
|
80
|
-
cache_service: rails_config[:cache_service]
|
81
|
-
tracer: rails_config[:tracer]
|
78
|
+
cache_service: rails_config[:cache_service]
|
82
79
|
)
|
83
80
|
end
|
84
81
|
|
@@ -87,8 +84,7 @@ module Datadog
|
|
87
84
|
|
88
85
|
datadog_config.use(
|
89
86
|
:action_cable,
|
90
|
-
service_name: "#{rails_config[:service_name]}-#{Contrib::ActionCable::Ext::SERVICE_NAME}"
|
91
|
-
tracer: rails_config[:tracer]
|
87
|
+
service_name: "#{rails_config[:service_name]}-#{Contrib::ActionCable::Ext::SERVICE_NAME}"
|
92
88
|
)
|
93
89
|
end
|
94
90
|
|
@@ -101,8 +97,7 @@ module Datadog
|
|
101
97
|
|
102
98
|
datadog_config.use(
|
103
99
|
:action_pack,
|
104
|
-
service_name: rails_config[:service_name]
|
105
|
-
tracer: rails_config[:tracer]
|
100
|
+
service_name: rails_config[:service_name]
|
106
101
|
)
|
107
102
|
end
|
108
103
|
|
@@ -111,8 +106,7 @@ module Datadog
|
|
111
106
|
|
112
107
|
datadog_config.use(
|
113
108
|
:action_view,
|
114
|
-
service_name: rails_config[:service_name]
|
115
|
-
tracer: rails_config[:tracer]
|
109
|
+
service_name: rails_config[:service_name]
|
116
110
|
)
|
117
111
|
end
|
118
112
|
|
@@ -121,8 +115,7 @@ module Datadog
|
|
121
115
|
|
122
116
|
datadog_config.use(
|
123
117
|
:active_record,
|
124
|
-
service_name: rails_config[:database_service]
|
125
|
-
tracer: rails_config[:tracer]
|
118
|
+
service_name: rails_config[:database_service]
|
126
119
|
)
|
127
120
|
end
|
128
121
|
end
|
@@ -36,7 +36,7 @@ module Datadog
|
|
36
36
|
Datadog.configuration[:sequel][:service_name] || adapter_name,
|
37
37
|
app: Ext::APP,
|
38
38
|
app_type: Datadog::Ext::AppTypes::DB,
|
39
|
-
tracer: Datadog.configuration[:sequel][:tracer]
|
39
|
+
tracer: -> { Datadog.configuration[:sequel][:tracer] }
|
40
40
|
)
|
41
41
|
end
|
42
42
|
|
data/lib/ddtrace/pin.rb
CHANGED
@@ -18,13 +18,15 @@ module Datadog
|
|
18
18
|
attr_accessor :name
|
19
19
|
attr_accessor :service_name
|
20
20
|
attr_accessor :tags
|
21
|
-
|
21
|
+
attr_reader :tracer
|
22
22
|
attr_accessor :writer
|
23
23
|
|
24
24
|
alias service= service_name=
|
25
25
|
alias service service_name
|
26
26
|
|
27
27
|
def initialize(service_name, options = {})
|
28
|
+
deprecation_warning unless options[:tracer].is_a?(Proc) || options[:tracer].nil?
|
29
|
+
|
28
30
|
@app = options[:app]
|
29
31
|
@app_type = options[:app_type]
|
30
32
|
@config = options[:config]
|
@@ -35,7 +37,7 @@ module Datadog
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def tracer
|
38
|
-
@tracer || Datadog.tracer
|
40
|
+
@tracer.is_a?(Proc) ? @tracer.call : (@tracer || Datadog.tracer)
|
39
41
|
end
|
40
42
|
|
41
43
|
def enabled?
|
@@ -67,6 +69,27 @@ module Datadog
|
|
67
69
|
def to_s
|
68
70
|
"Pin(service:#{service},app:#{app},app_type:#{app_type},name:#{name})"
|
69
71
|
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
DEPRECATION_WARNING = %(
|
76
|
+
Explicitly providing a tracer instance is DEPRECATED.
|
77
|
+
It's recommended to not provide an explicit tracer instance
|
78
|
+
and let Datadog::Pin resolve the correct tracer internally.
|
79
|
+
).freeze
|
80
|
+
|
81
|
+
def deprecation_warning
|
82
|
+
log_deprecation_warning('Datadog::Pin.new')
|
83
|
+
end
|
84
|
+
|
85
|
+
include Datadog::Patcher
|
86
|
+
|
87
|
+
def log_deprecation_warning(method_name)
|
88
|
+
# Only log each deprecation warning once (safeguard against log spam)
|
89
|
+
do_once(method_name) do
|
90
|
+
Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
|
91
|
+
end
|
92
|
+
end
|
70
93
|
end
|
71
94
|
|
72
95
|
# Modification to Pin which logs deprecation warnings if accessed.
|
data/lib/ddtrace/tracer.rb
CHANGED
@@ -314,7 +314,7 @@ module Datadog
|
|
314
314
|
def record_context(context)
|
315
315
|
trace = @context_flush.consume!(context)
|
316
316
|
|
317
|
-
write(trace) if trace && !trace.empty?
|
317
|
+
write(trace) if @enabled && trace && !trace.empty?
|
318
318
|
end
|
319
319
|
|
320
320
|
# Return the current active span or +nil+.
|
@@ -335,7 +335,7 @@ module Datadog
|
|
335
335
|
# Send the trace to the writer to enqueue the spans list in the agent
|
336
336
|
# sending queue.
|
337
337
|
def write(trace)
|
338
|
-
return if @writer.nil?
|
338
|
+
return if @writer.nil?
|
339
339
|
|
340
340
|
if Datadog.configuration.diagnostics.debug
|
341
341
|
Datadog.logger.debug("Writing #{trace.length} spans (enabled: #{@enabled})")
|
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.37.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -122,6 +122,34 @@ dependencies:
|
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 5.10.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: minitest-around
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.5.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.5.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: minitest-stub_any_instance
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.0.2
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.0.2
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: appraisal
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +248,48 @@ dependencies:
|
|
220
248
|
- - "~>"
|
221
249
|
- !ruby/object:Gem::Version
|
222
250
|
version: 2.4.0
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: benchmark-ips
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '2.8'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '2.8'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: benchmark-memory
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0.1'
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0.1'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: memory_profiler
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - "~>"
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0.9'
|
286
|
+
type: :development
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - "~>"
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '0.9'
|
223
293
|
- !ruby/object:Gem::Dependency
|
224
294
|
name: redcarpet
|
225
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,6 +370,7 @@ files:
|
|
300
370
|
- ".env"
|
301
371
|
- ".github/CODEOWNERS"
|
302
372
|
- ".gitignore"
|
373
|
+
- ".gitlab-ci.yml"
|
303
374
|
- ".rspec"
|
304
375
|
- ".rubocop.yml"
|
305
376
|
- ".yardopts"
|