ddtrace 0.14.0.beta2 → 0.14.0.rc1
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/Appraisals +6 -0
- data/CHANGELOG.md +31 -2
- data/Gemfile +1 -0
- data/Rakefile +8 -1
- data/docs/GettingStarted.md +34 -1
- data/lib/ddtrace.rb +1 -0
- data/lib/ddtrace/context.rb +8 -0
- data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +22 -0
- data/lib/ddtrace/contrib/rest_client/integration.rb +27 -0
- data/lib/ddtrace/contrib/rest_client/patcher.rb +25 -0
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +90 -0
- data/lib/ddtrace/propagation/http_propagator.rb +6 -0
- data/lib/ddtrace/span.rb +0 -1
- data/lib/ddtrace/tracer.rb +5 -0
- data/lib/ddtrace/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4577cdbdd06aac09ea0083d53eb9770be92e4731477c79b75486b31f020668d7
|
|
4
|
+
data.tar.gz: 523b5f41156dbef1e860ddb209109af347bfd9af8b9d949edb1ea9638e16a670
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c389d698936501fd887a41d2e2dbe524abcb44ffd84d81147372914c96040e8964a0888d51731cbfb6538c25f556c2b9d56cea16d6de8591cd99724a3386b61
|
|
7
|
+
data.tar.gz: 8b0b647de877011b9fe16e1db64f8e42c98807e40f64dd629ee6be360ef9da9992446d44e7ff5f8a87e1f6fb0f8f903d4bb5bbd4dc5770ea2f26e898765d7be0
|
data/Appraisals
CHANGED
|
@@ -80,6 +80,7 @@ elsif Gem::Version.new('1.9.3') <= Gem::Version.new(RUBY_VERSION) \
|
|
|
80
80
|
gem 'rack-test', '0.7.0'
|
|
81
81
|
gem 'rake', '< 12.3'
|
|
82
82
|
gem 'redis', '< 4.0'
|
|
83
|
+
gem 'rest-client', '< 2.0'
|
|
83
84
|
gem 'resque', '< 2.0'
|
|
84
85
|
gem 'sequel', '~> 4.0', '< 4.37'
|
|
85
86
|
gem 'sidekiq', '4.0.0'
|
|
@@ -162,6 +163,7 @@ elsif Gem::Version.new('2.0.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
|
162
163
|
gem 'rack-test', '0.7.0'
|
|
163
164
|
gem 'rake', '< 12.3'
|
|
164
165
|
gem 'redis', '< 4.0'
|
|
166
|
+
gem 'rest-client'
|
|
165
167
|
gem 'resque', '< 2.0'
|
|
166
168
|
gem 'sequel', '~> 4.0', '< 4.37'
|
|
167
169
|
gem 'sidekiq', '4.0.0'
|
|
@@ -264,6 +266,7 @@ elsif Gem::Version.new('2.1.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
|
264
266
|
gem 'rack-test', '0.7.0'
|
|
265
267
|
gem 'rake', '< 12.3'
|
|
266
268
|
gem 'redis', '< 4.0'
|
|
269
|
+
gem 'rest-client'
|
|
267
270
|
gem 'resque', '< 2.0'
|
|
268
271
|
gem 'sequel', '~> 4.0', '< 4.37'
|
|
269
272
|
gem 'sidekiq', '4.0.0'
|
|
@@ -400,6 +403,7 @@ elsif Gem::Version.new('2.2.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
|
400
403
|
gem 'rack-test'
|
|
401
404
|
gem 'rake', '>= 12.3'
|
|
402
405
|
gem 'redis', '< 4.0'
|
|
406
|
+
gem 'rest-client'
|
|
403
407
|
gem 'resque', '< 2.0'
|
|
404
408
|
gem 'sequel'
|
|
405
409
|
gem 'sidekiq'
|
|
@@ -536,6 +540,7 @@ elsif Gem::Version.new('2.3.0') <= Gem::Version.new(RUBY_VERSION) \
|
|
|
536
540
|
gem 'rack-test'
|
|
537
541
|
gem 'rake', '>= 12.3'
|
|
538
542
|
gem 'redis', '< 4.0'
|
|
543
|
+
gem 'rest-client'
|
|
539
544
|
gem 'resque', '< 2.0'
|
|
540
545
|
gem 'sequel'
|
|
541
546
|
gem 'sidekiq'
|
|
@@ -566,6 +571,7 @@ elsif Gem::Version.new('2.4.0') <= Gem::Version.new(RUBY_VERSION)
|
|
|
566
571
|
gem 'rack-test'
|
|
567
572
|
gem 'rake', '>= 12.3'
|
|
568
573
|
gem 'redis', '< 4.0'
|
|
574
|
+
gem 'rest-client'
|
|
569
575
|
gem 'resque', '< 2.0'
|
|
570
576
|
gem 'sequel'
|
|
571
577
|
gem 'sidekiq'
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased (beta)]
|
|
6
6
|
|
|
7
|
+
## [0.14.0.rc1] - 2018-08-08
|
|
8
|
+
|
|
9
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.14.0.rc1
|
|
10
|
+
|
|
11
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.14.0.beta2...v0.14.0.rc1
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- RestClient integration (#422, #460)
|
|
16
|
+
- Tracer#active_root_span helper (#503)
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Context propagation for distributed traces when context is full (#502)
|
|
21
|
+
|
|
7
22
|
## [0.14.0.beta2] - 2018-07-25
|
|
8
23
|
|
|
9
24
|
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.14.0.beta2
|
|
@@ -36,6 +51,16 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.13.1...v0.14.0.beta1
|
|
|
36
51
|
- DelayedJob integration (#393 #444)
|
|
37
52
|
- Version information to integrations (#483)
|
|
38
53
|
|
|
54
|
+
## [0.13.2] - 2018-08-07
|
|
55
|
+
|
|
56
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.13.2
|
|
57
|
+
|
|
58
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.13.1...v0.13.2
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- Context propagation for distributed traces when context is full (#502)
|
|
63
|
+
|
|
39
64
|
## [0.13.1] - 2018-07-17
|
|
40
65
|
|
|
41
66
|
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.13.1
|
|
@@ -410,8 +435,12 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
|
|
|
410
435
|
|
|
411
436
|
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
412
437
|
|
|
413
|
-
[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.
|
|
414
|
-
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.
|
|
438
|
+
[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.2...master
|
|
439
|
+
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.14.rc1...0.14-dev
|
|
440
|
+
[0.14.0.rc1]: https://github.com/DataDog/dd-trace-rb/compare/v0.14.0.beta2...v0.14.rc1
|
|
441
|
+
[0.14.0.beta2]: https://github.com/DataDog/dd-trace-rb/compare/v0.14.0.beta1...v0.14.beta2
|
|
442
|
+
[0.14.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...v0.14.beta1
|
|
443
|
+
[0.13.2]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.1...v0.13.2
|
|
415
444
|
[0.13.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...v0.13.1
|
|
416
445
|
[0.13.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.12.1...v0.13.0
|
|
417
446
|
[0.13.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0...v0.13.0.beta1
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
|
@@ -67,7 +67,8 @@ namespace :spec do
|
|
|
67
67
|
:sequel,
|
|
68
68
|
:sidekiq,
|
|
69
69
|
:sinatra,
|
|
70
|
-
:sucker_punch
|
|
70
|
+
:sucker_punch,
|
|
71
|
+
:rest_client
|
|
71
72
|
].each do |contrib|
|
|
72
73
|
RSpec::Core::RakeTask.new(contrib) do |t|
|
|
73
74
|
t.pattern = "spec/ddtrace/contrib/#{contrib}/**/*_spec.rb"
|
|
@@ -240,6 +241,7 @@ task :ci do
|
|
|
240
241
|
sh 'bundle exec appraisal contrib-old rake spec:redis'
|
|
241
242
|
sh 'bundle exec appraisal contrib-old rake spec:resque'
|
|
242
243
|
sh 'bundle exec appraisal contrib-old rake spec:sequel'
|
|
244
|
+
sh 'bundle exec appraisal contrib-old rake spec:rest_client'
|
|
243
245
|
# Rails minitests
|
|
244
246
|
sh 'bundle exec appraisal rails30-postgres rake test:rails'
|
|
245
247
|
sh 'bundle exec appraisal rails30-postgres rake test:railsdisableenv'
|
|
@@ -284,6 +286,7 @@ task :ci do
|
|
|
284
286
|
sh 'bundle exec appraisal contrib-old rake spec:redis'
|
|
285
287
|
sh 'bundle exec appraisal contrib-old rake spec:resque'
|
|
286
288
|
sh 'bundle exec appraisal contrib-old rake spec:sequel'
|
|
289
|
+
sh 'bundle exec appraisal contrib-old rake spec:rest_client'
|
|
287
290
|
# Rails minitests
|
|
288
291
|
sh 'bundle exec appraisal contrib-old rake test:sidekiq'
|
|
289
292
|
sh 'bundle exec appraisal rails30-postgres rake test:rails'
|
|
@@ -331,6 +334,7 @@ task :ci do
|
|
|
331
334
|
sh 'bundle exec appraisal contrib-old rake spec:redis'
|
|
332
335
|
sh 'bundle exec appraisal contrib-old rake spec:resque'
|
|
333
336
|
sh 'bundle exec appraisal contrib-old rake spec:sequel'
|
|
337
|
+
sh 'bundle exec appraisal contrib-old rake spec:rest_client'
|
|
334
338
|
# Rails minitests
|
|
335
339
|
sh 'bundle exec appraisal contrib-old rake test:sidekiq'
|
|
336
340
|
sh 'bundle exec appraisal rails30-postgres rake test:rails'
|
|
@@ -387,6 +391,7 @@ task :ci do
|
|
|
387
391
|
sh 'bundle exec appraisal contrib rake spec:redis'
|
|
388
392
|
sh 'bundle exec appraisal contrib rake spec:resque'
|
|
389
393
|
sh 'bundle exec appraisal contrib rake spec:sequel'
|
|
394
|
+
sh 'bundle exec appraisal contrib rake spec:rest_client'
|
|
390
395
|
# Rails minitests
|
|
391
396
|
sh 'bundle exec appraisal contrib rake test:sidekiq'
|
|
392
397
|
sh 'bundle exec appraisal rails30-postgres rake test:rails'
|
|
@@ -451,6 +456,7 @@ task :ci do
|
|
|
451
456
|
sh 'bundle exec appraisal contrib rake spec:redis'
|
|
452
457
|
sh 'bundle exec appraisal contrib rake spec:resque'
|
|
453
458
|
sh 'bundle exec appraisal contrib rake spec:sequel'
|
|
459
|
+
sh 'bundle exec appraisal contrib rake spec:rest_client'
|
|
454
460
|
# Rails minitests
|
|
455
461
|
sh 'bundle exec appraisal contrib rake test:sidekiq'
|
|
456
462
|
sh 'bundle exec appraisal rails30-postgres rake test:rails'
|
|
@@ -514,6 +520,7 @@ task :ci do
|
|
|
514
520
|
sh 'bundle exec appraisal contrib rake spec:redis'
|
|
515
521
|
sh 'bundle exec appraisal contrib rake spec:resque'
|
|
516
522
|
sh 'bundle exec appraisal contrib rake spec:sequel'
|
|
523
|
+
sh 'bundle exec appraisal contrib rake spec:rest_client'
|
|
517
524
|
# Rails minitests
|
|
518
525
|
sh 'bundle exec appraisal contrib rake test:sidekiq'
|
|
519
526
|
sh 'bundle exec rake benchmark'
|
data/docs/GettingStarted.md
CHANGED
|
@@ -41,6 +41,7 @@ For descriptions of terminology used in APM, take a look at the [official docume
|
|
|
41
41
|
- [Rails](#rails)
|
|
42
42
|
- [Rake](#rake)
|
|
43
43
|
- [Redis](#redis)
|
|
44
|
+
- [Rest Client](#restclient)
|
|
44
45
|
- [Resque](#resque)
|
|
45
46
|
- [Sequel](#sequel)
|
|
46
47
|
- [Sidekiq](#sidekiq)
|
|
@@ -229,7 +230,7 @@ def finish(name, id, payload)
|
|
|
229
230
|
end
|
|
230
231
|
end
|
|
231
232
|
```
|
|
232
|
-
#####Enriching traces from nested methods
|
|
233
|
+
##### Enriching traces from nested methods
|
|
233
234
|
|
|
234
235
|
You can tag additional information to current active span from any method. Note however that if the method is called and there is no span currently active `active_span` will be nil.
|
|
235
236
|
|
|
@@ -240,6 +241,15 @@ current_span = Datadog.tracer.active_span
|
|
|
240
241
|
current_span.set_tag('my_tag', 'my_value') unless current_span.nil?
|
|
241
242
|
```
|
|
242
243
|
|
|
244
|
+
You can also get the root span of the current active trace using the `active_root_span` method. This method will return `nil` if there is no active trace.
|
|
245
|
+
|
|
246
|
+
```ruby
|
|
247
|
+
# e.g. adding tag to active root span
|
|
248
|
+
|
|
249
|
+
current_root_span = Datadog.tracer.active_root_span
|
|
250
|
+
current_root_span.set_tag('my_tag', 'my_value') unless current_root_span.nil?
|
|
251
|
+
```
|
|
252
|
+
|
|
243
253
|
## Integration instrumentation
|
|
244
254
|
|
|
245
255
|
Many popular libraries and frameworks are supported out-of-the-box, which can be auto-instrumented. Although they are not activated automatically, they can be easily activated and configured by using the `Datadog.configure` API:
|
|
@@ -275,6 +285,7 @@ For a list of available integrations, and their configuration options, please re
|
|
|
275
285
|
| Rails | `rails` | `>= 3.2, < 5.2` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
|
|
276
286
|
| Rake | `rake` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
|
|
277
287
|
| Redis | `redis` | `>= 3.2, < 4.0` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
|
|
288
|
+
| Rest Client | `rest-client` | `>= 1.8` | *[Link](#restclient)* | *[Link](https://github.com/rest-client/rest-client)* |
|
|
278
289
|
| Resque | `resque` | `>= 1.0, < 2.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
|
|
279
290
|
| Sequel | `sequel` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
|
|
280
291
|
| Sidekiq | `sidekiq` | `>= 4.0` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
|
|
@@ -936,6 +947,27 @@ customer_cache.get(...) # traced call will belong to `customer-cache` service
|
|
|
936
947
|
invoice_cache.get(...) # traced call will belong to `invoice-cache` service
|
|
937
948
|
```
|
|
938
949
|
|
|
950
|
+
### Rest Client
|
|
951
|
+
|
|
952
|
+
The `rest-client` integration is available through the `ddtrace` middleware:
|
|
953
|
+
|
|
954
|
+
```ruby
|
|
955
|
+
require 'rest_client'
|
|
956
|
+
require 'ddtrace'
|
|
957
|
+
|
|
958
|
+
Datadog.configure do |c|
|
|
959
|
+
c.use :rest_client, service_name: 'rest_client' # global service name
|
|
960
|
+
end
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
Where `options` is an optional `Hash` that accepts the following parameters:
|
|
964
|
+
|
|
965
|
+
| Key | Description | Default |
|
|
966
|
+
| --- | --- | --- |
|
|
967
|
+
| `service_name` | Service name for Rest Client instrumentation. | `'rest_client'` |
|
|
968
|
+
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `false` |
|
|
969
|
+
| `tracer` | A `Datadog::Tracer` instance used to instrument the application. Usually you don't need to set that. | `Datadog.tracer` |
|
|
970
|
+
|
|
939
971
|
### Resque
|
|
940
972
|
|
|
941
973
|
The Resque integration uses Resque hooks that wraps the ``perform`` method.
|
|
@@ -1326,6 +1358,7 @@ For more details on how to activate distributed tracing for integrations, see th
|
|
|
1326
1358
|
|
|
1327
1359
|
- [Excon](#excon)
|
|
1328
1360
|
- [Faraday](#faraday)
|
|
1361
|
+
- [Rest Client](#restclient)
|
|
1329
1362
|
- [Net/HTTP](#nethttp)
|
|
1330
1363
|
- [Rack](#rack)
|
|
1331
1364
|
- [Rails](#rails)
|
data/lib/ddtrace.rb
CHANGED
|
@@ -59,6 +59,7 @@ require 'ddtrace/contrib/redis/patcher'
|
|
|
59
59
|
require 'ddtrace/contrib/http/patcher'
|
|
60
60
|
require 'ddtrace/contrib/aws/patcher'
|
|
61
61
|
require 'ddtrace/contrib/sucker_punch/patcher'
|
|
62
|
+
require 'ddtrace/contrib/rest_client/integration'
|
|
62
63
|
require 'ddtrace/contrib/mongodb/patcher'
|
|
63
64
|
require 'ddtrace/contrib/dalli/patcher'
|
|
64
65
|
require 'ddtrace/contrib/rake/patcher'
|
data/lib/ddtrace/context.rb
CHANGED
|
@@ -63,6 +63,12 @@ module Datadog
|
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def current_root_span
|
|
67
|
+
@mutex.synchronize do
|
|
68
|
+
return @current_root_span
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
66
72
|
# Add a span to the context trace list, keeping it as the last active span.
|
|
67
73
|
def add_span(span)
|
|
68
74
|
@mutex.synchronize do
|
|
@@ -77,6 +83,7 @@ module Datadog
|
|
|
77
83
|
return
|
|
78
84
|
end
|
|
79
85
|
set_current_span(span)
|
|
86
|
+
@current_root_span = span if @trace.empty?
|
|
80
87
|
@trace << span
|
|
81
88
|
span.context = self
|
|
82
89
|
end
|
|
@@ -158,6 +165,7 @@ module Datadog
|
|
|
158
165
|
@sampling_priority = options.fetch(:sampling_priority, nil)
|
|
159
166
|
@finished_spans = 0
|
|
160
167
|
@current_span = nil
|
|
168
|
+
@current_root_span = nil
|
|
161
169
|
end
|
|
162
170
|
|
|
163
171
|
def set_current_span(span)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'ddtrace/contrib/configuration/settings'
|
|
2
|
+
require 'ddtrace/contrib/active_record/utils'
|
|
3
|
+
|
|
4
|
+
module Datadog
|
|
5
|
+
module Contrib
|
|
6
|
+
module RestClient
|
|
7
|
+
module Configuration
|
|
8
|
+
# Unique settings for RestClient
|
|
9
|
+
class Settings < Contrib::Configuration::Settings
|
|
10
|
+
NAME = 'rest_client'.freeze
|
|
11
|
+
|
|
12
|
+
option :service_name, default: NAME, depends_on: [:tracer] do |value|
|
|
13
|
+
get_option(:tracer).set_service_info(value, NAME, Ext::AppTypes::DB)
|
|
14
|
+
value
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
option :distributed_tracing, default: false
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'ddtrace/contrib/integration'
|
|
2
|
+
require 'ddtrace/contrib/rest_client/configuration/settings'
|
|
3
|
+
require 'ddtrace/contrib/rest_client/patcher'
|
|
4
|
+
|
|
5
|
+
module Datadog
|
|
6
|
+
module Contrib
|
|
7
|
+
module RestClient
|
|
8
|
+
# Description of RestClient integration
|
|
9
|
+
class Integration
|
|
10
|
+
include Contrib::Integration
|
|
11
|
+
register_as :rest_client
|
|
12
|
+
|
|
13
|
+
def self.compatible?
|
|
14
|
+
RUBY_VERSION >= '1.9.3' && defined?(::RestClient::Request)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def default_configuration
|
|
18
|
+
Configuration::Settings.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def patcher
|
|
22
|
+
Patcher
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Datadog
|
|
2
|
+
module Contrib
|
|
3
|
+
module RestClient
|
|
4
|
+
# RestClient integration
|
|
5
|
+
module Patcher
|
|
6
|
+
include Contrib::Patcher
|
|
7
|
+
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
def patched?
|
|
11
|
+
done?(:rest_client)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def patch
|
|
15
|
+
do_once(:rest_client) do
|
|
16
|
+
require 'ddtrace/ext/app_types'
|
|
17
|
+
require 'ddtrace/contrib/rest_client/request_patch'
|
|
18
|
+
|
|
19
|
+
::RestClient::Request.send(:include, RequestPatch)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require 'ddtrace/ext/net'
|
|
2
|
+
require 'ddtrace/ext/distributed'
|
|
3
|
+
require 'ddtrace/propagation/http_propagator'
|
|
4
|
+
|
|
5
|
+
module Datadog
|
|
6
|
+
module Contrib
|
|
7
|
+
module RestClient
|
|
8
|
+
# RestClient RequestPatch
|
|
9
|
+
module RequestPatch
|
|
10
|
+
REQUEST_TRACE_NAME = 'rest_client.request'.freeze
|
|
11
|
+
|
|
12
|
+
def self.included(base)
|
|
13
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
|
|
14
|
+
base.class_eval do
|
|
15
|
+
alias_method :execute_without_datadog, :execute
|
|
16
|
+
remove_method :execute
|
|
17
|
+
include InstanceMethods
|
|
18
|
+
end
|
|
19
|
+
else
|
|
20
|
+
base.send(:prepend, InstanceMethods)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Compatibility shim for Rubies not supporting `.prepend`
|
|
25
|
+
module InstanceMethodsCompatibility
|
|
26
|
+
def execute(&block)
|
|
27
|
+
execute_without_datadog(&block)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# InstanceMethods - implementing instrumentation
|
|
32
|
+
module InstanceMethods
|
|
33
|
+
include InstanceMethodsCompatibility unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0.0')
|
|
34
|
+
|
|
35
|
+
def execute(&block)
|
|
36
|
+
uri = URI.parse(url)
|
|
37
|
+
|
|
38
|
+
return super(&block) unless datadog_configuration[:tracer].enabled
|
|
39
|
+
|
|
40
|
+
datadog_trace_request(uri) do |span|
|
|
41
|
+
if datadog_configuration[:distributed_tracing]
|
|
42
|
+
Datadog::HTTPPropagator.inject!(span.context, processed_headers)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
super(&block)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def datadog_tag_request(uri, span)
|
|
50
|
+
span.resource = method.to_s.upcase
|
|
51
|
+
span.set_tag(Ext::HTTP::URL, uri.path)
|
|
52
|
+
span.set_tag(Ext::HTTP::METHOD, method.to_s.upcase)
|
|
53
|
+
span.set_tag(Ext::NET::TARGET_HOST, uri.host)
|
|
54
|
+
span.set_tag(Ext::NET::TARGET_PORT, uri.port)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def datadog_trace_request(uri)
|
|
58
|
+
span = datadog_configuration[:tracer].trace(REQUEST_TRACE_NAME,
|
|
59
|
+
service: datadog_configuration[:service_name],
|
|
60
|
+
span_type: Datadog::Ext::AppTypes::WEB)
|
|
61
|
+
|
|
62
|
+
datadog_tag_request(uri, span)
|
|
63
|
+
|
|
64
|
+
response = yield(span)
|
|
65
|
+
|
|
66
|
+
span.set_tag(Ext::HTTP::STATUS_CODE, response.code)
|
|
67
|
+
response
|
|
68
|
+
rescue ::RestClient::ExceptionWithResponse => e
|
|
69
|
+
span.set_error(e) if Ext::HTTP::ERROR_RANGE.cover?(e.http_code)
|
|
70
|
+
span.set_tag(Ext::HTTP::STATUS_CODE, e.http_code)
|
|
71
|
+
|
|
72
|
+
raise e
|
|
73
|
+
# rubocop:disable Lint/RescueException
|
|
74
|
+
rescue Exception => e
|
|
75
|
+
# rubocop:enable Lint/RescueException
|
|
76
|
+
span.set_error(e)
|
|
77
|
+
|
|
78
|
+
raise e
|
|
79
|
+
ensure
|
|
80
|
+
span.finish
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def datadog_configuration
|
|
84
|
+
Datadog.configuration[:rest_client]
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -9,6 +9,12 @@ module Datadog
|
|
|
9
9
|
|
|
10
10
|
# inject! popolates the env with span ID, trace ID and sampling priority
|
|
11
11
|
def self.inject!(context, env)
|
|
12
|
+
# Prevent propagation from being attempted if context provided is nil.
|
|
13
|
+
if context.nil?
|
|
14
|
+
Datadog::Tracer.log.debug('Cannot inject context into env to propagate over HTTP: context is nil.'.freeze)
|
|
15
|
+
return
|
|
16
|
+
end
|
|
17
|
+
|
|
12
18
|
env[HTTP_HEADER_TRACE_ID] = context.trace_id.to_s
|
|
13
19
|
env[HTTP_HEADER_PARENT_ID] = context.span_id.to_s
|
|
14
20
|
env[HTTP_HEADER_SAMPLING_PRIORITY] = context.sampling_priority.to_s
|
data/lib/ddtrace/span.rb
CHANGED
data/lib/ddtrace/tracer.rb
CHANGED
|
@@ -346,6 +346,11 @@ module Datadog
|
|
|
346
346
|
call_context.current_span
|
|
347
347
|
end
|
|
348
348
|
|
|
349
|
+
# Return the current active root span or +nil+.
|
|
350
|
+
def active_root_span
|
|
351
|
+
call_context.current_root_span
|
|
352
|
+
end
|
|
353
|
+
|
|
349
354
|
# Send the trace to the writer to enqueue the spans list in the agent
|
|
350
355
|
# sending queue.
|
|
351
356
|
def write(trace)
|
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.14.0.
|
|
4
|
+
version: 0.14.0.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Datadog, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: msgpack
|
|
@@ -361,6 +361,10 @@ files:
|
|
|
361
361
|
- lib/ddtrace/contrib/registerable.rb
|
|
362
362
|
- lib/ddtrace/contrib/resque/patcher.rb
|
|
363
363
|
- lib/ddtrace/contrib/resque/resque_job.rb
|
|
364
|
+
- lib/ddtrace/contrib/rest_client/configuration/settings.rb
|
|
365
|
+
- lib/ddtrace/contrib/rest_client/integration.rb
|
|
366
|
+
- lib/ddtrace/contrib/rest_client/patcher.rb
|
|
367
|
+
- lib/ddtrace/contrib/rest_client/request_patch.rb
|
|
364
368
|
- lib/ddtrace/contrib/sequel/configuration/settings.rb
|
|
365
369
|
- lib/ddtrace/contrib/sequel/database.rb
|
|
366
370
|
- lib/ddtrace/contrib/sequel/dataset.rb
|