ddtrace 0.13.0 → 0.13.1
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 +88 -6
- data/CHANGELOG.md +19 -0
- data/Rakefile +6 -0
- data/benchmarks/postgres_database.yml +9 -0
- data/benchmarks/sidekiq_test.rb +154 -0
- data/ddtrace.gemspec +3 -0
- data/docs/GettingStarted.md +30 -5
- data/lib/ddtrace.rb +3 -14
- data/lib/ddtrace/configuration.rb +1 -1
- data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +2 -1
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace/workers.rb +6 -4
- data/lib/ddtrace/writer.rb +4 -5
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d35e4bd757dc77db293835d432a10cd51ad1d28
|
4
|
+
data.tar.gz: e1e6eb937c6be61d0fcea356ed23c2edc4f33991
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17e882a034471da9d5f032c0b4f2b3e243b7a85452a51994439423a2950ead7927e2bf98d9f8922751f32b749ea8975230f34001960f153822ae9efcd12d2051
|
7
|
+
data.tar.gz: b5bb863b4f742be7479fe02a311c956cf41ed1f8b2eb8c8796ee2fb1a4a1f4cc093655252b9a3d43ec5597e48b96bdd8382a68ef90bb1761ad8383a83351077d
|
data/.circleci/config.yml
CHANGED
@@ -83,6 +83,21 @@ step_run_all_tests: &step_run_all_tests
|
|
83
83
|
run:
|
84
84
|
name: Run tests
|
85
85
|
command: bundle exec rake ci
|
86
|
+
step_release_docs: &step_release_docs
|
87
|
+
run:
|
88
|
+
name: Upload release docs
|
89
|
+
command: S3_DIR=trace bundle exec rake release:docs
|
90
|
+
|
91
|
+
filters_all_branches_and_tags: &filters_all_branches_and_tags
|
92
|
+
filters:
|
93
|
+
tags:
|
94
|
+
only: /.*/
|
95
|
+
filters_only_release_tags: &filters_only_release_tags
|
96
|
+
filters:
|
97
|
+
branches:
|
98
|
+
ignore: /.*/
|
99
|
+
tags:
|
100
|
+
only: /^v\d+(\.\d+){0,3}(\.(alpha|beta|rc)\d+)?$/
|
86
101
|
|
87
102
|
version: 2.0
|
88
103
|
jobs:
|
@@ -364,6 +379,29 @@ jobs:
|
|
364
379
|
keys:
|
365
380
|
- '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.3-{{ checksum ".circleci/bundle_checksum" }}'
|
366
381
|
- *step_run_all_tests
|
382
|
+
benchmark-2.3:
|
383
|
+
<<: *job_defaults
|
384
|
+
docker:
|
385
|
+
- <<: *container-2_3
|
386
|
+
environment:
|
387
|
+
- TEST_DATADOG_INTEGRATION: 1
|
388
|
+
- *container_postgres
|
389
|
+
- *container_redis
|
390
|
+
- *container_agent
|
391
|
+
steps:
|
392
|
+
- restore_cache:
|
393
|
+
keys:
|
394
|
+
- '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.3-{{ .Environment.CIRCLE_SHA1 }}'
|
395
|
+
- restore_cache:
|
396
|
+
keys:
|
397
|
+
- '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.3-{{ checksum ".circleci/bundle_checksum" }}'
|
398
|
+
- run:
|
399
|
+
name: Run Benchmark
|
400
|
+
command: bundle exec appraisal rails5-postgres-sidekiq ruby benchmarks/sidekiq_test.rb 2>&1 1> /dev/null | tee benchmark_results.csv
|
401
|
+
- run:
|
402
|
+
name: Run Benchmark without ddtracer
|
403
|
+
command: rm -f lib/ddtrace.rb && bundle exec appraisal rails5-postgres-sidekiq ruby benchmarks/sidekiq_test.rb 2>&1 1> /dev/null | tee benchmark_results.csv
|
404
|
+
|
367
405
|
checkout-2.4:
|
368
406
|
<<: *job_defaults
|
369
407
|
docker:
|
@@ -420,49 +458,93 @@ jobs:
|
|
420
458
|
keys:
|
421
459
|
- '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.4-{{ checksum ".circleci/bundle_checksum" }}'
|
422
460
|
- *step_run_all_tests
|
461
|
+
deploy-release:
|
462
|
+
<<: *job_defaults
|
463
|
+
docker:
|
464
|
+
- *container-2_4
|
465
|
+
steps:
|
466
|
+
- checkout
|
467
|
+
- run:
|
468
|
+
command: |
|
469
|
+
apt-get -y -qq update
|
470
|
+
apt-get -y -qq install awscli
|
471
|
+
- *step_bundle_install
|
472
|
+
- *step_release_docs
|
473
|
+
|
423
474
|
workflows:
|
424
475
|
version: 2
|
425
476
|
build-and-test:
|
426
477
|
jobs:
|
427
|
-
- checkout-1.9
|
478
|
+
- checkout-1.9:
|
479
|
+
<<: *filters_all_branches_and_tags
|
428
480
|
- build-1.9:
|
481
|
+
<<: *filters_all_branches_and_tags
|
429
482
|
requires:
|
430
483
|
- checkout-1.9
|
431
484
|
- test-1.9:
|
485
|
+
<<: *filters_all_branches_and_tags
|
432
486
|
requires:
|
433
487
|
- build-1.9
|
434
|
-
- checkout-2.0
|
488
|
+
- checkout-2.0:
|
489
|
+
<<: *filters_all_branches_and_tags
|
435
490
|
- build-2.0:
|
491
|
+
<<: *filters_all_branches_and_tags
|
436
492
|
requires:
|
437
493
|
- checkout-2.0
|
438
494
|
- test-2.0:
|
495
|
+
<<: *filters_all_branches_and_tags
|
439
496
|
requires:
|
440
497
|
- build-2.0
|
441
|
-
- checkout-2.1
|
498
|
+
- checkout-2.1:
|
499
|
+
<<: *filters_all_branches_and_tags
|
442
500
|
- build-2.1:
|
501
|
+
<<: *filters_all_branches_and_tags
|
443
502
|
requires:
|
444
503
|
- checkout-2.1
|
445
504
|
- test-2.1:
|
505
|
+
<<: *filters_all_branches_and_tags
|
446
506
|
requires:
|
447
507
|
- build-2.1
|
448
|
-
- checkout-2.2
|
508
|
+
- checkout-2.2:
|
509
|
+
<<: *filters_all_branches_and_tags
|
449
510
|
- build-2.2:
|
511
|
+
<<: *filters_all_branches_and_tags
|
450
512
|
requires:
|
451
513
|
- checkout-2.2
|
452
514
|
- test-2.2:
|
515
|
+
<<: *filters_all_branches_and_tags
|
453
516
|
requires:
|
454
517
|
- build-2.2
|
455
|
-
- checkout-2.3
|
518
|
+
- checkout-2.3:
|
519
|
+
<<: *filters_all_branches_and_tags
|
456
520
|
- build-2.3:
|
521
|
+
<<: *filters_all_branches_and_tags
|
457
522
|
requires:
|
458
523
|
- checkout-2.3
|
459
524
|
- test-2.3:
|
525
|
+
<<: *filters_all_branches_and_tags
|
460
526
|
requires:
|
461
527
|
- build-2.3
|
462
|
-
-
|
528
|
+
- benchmark-2.3:
|
529
|
+
<<: *filters_all_branches_and_tags
|
530
|
+
requires:
|
531
|
+
- build-2.3
|
532
|
+
- checkout-2.4:
|
533
|
+
<<: *filters_all_branches_and_tags
|
463
534
|
- build-2.4:
|
535
|
+
<<: *filters_all_branches_and_tags
|
464
536
|
requires:
|
465
537
|
- checkout-2.4
|
466
538
|
- test-2.4:
|
539
|
+
<<: *filters_all_branches_and_tags
|
467
540
|
requires:
|
468
541
|
- build-2.4
|
542
|
+
- deploy-release:
|
543
|
+
<<: *filters_only_release_tags
|
544
|
+
requires:
|
545
|
+
- test-1.9
|
546
|
+
- test-2.0
|
547
|
+
- test-2.1
|
548
|
+
- test-2.2
|
549
|
+
- test-2.3
|
550
|
+
- test-2.4
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,24 @@
|
|
4
4
|
|
5
5
|
## [Unreleased (beta)]
|
6
6
|
|
7
|
+
## [0.13.1] - 2018-07-17
|
8
|
+
|
9
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.13.1
|
10
|
+
|
11
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...v0.13.1
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- Configuration class variables don't lazy load (#477)
|
16
|
+
- Default tracer host `localhost` --> `127.0.0.1` (#466, #480) (@NobodysNightmare)
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Workers not shutting down quickly in some short running processes (#475)
|
21
|
+
- Missing documentation for mysql2 and Rails (#476, #488)
|
22
|
+
- Missing variable in rescue block (#481) (@kitop)
|
23
|
+
- Unclosed spans in ActiveSupport::Notifications with multithreading (#431, #478) (@senny)
|
24
|
+
|
7
25
|
## [0.13.0] - 2018-06-20
|
8
26
|
|
9
27
|
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.13.0
|
@@ -362,6 +380,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
362
380
|
|
363
381
|
[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...master
|
364
382
|
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...0.14-dev
|
383
|
+
[0.13.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...v0.13.1
|
365
384
|
[0.13.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.12.1...v0.13.0
|
366
385
|
[0.13.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0...v0.13.0.beta1
|
367
386
|
[0.12.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0...v0.12.1
|
data/Rakefile
CHANGED
@@ -223,6 +223,7 @@ task :ci do
|
|
223
223
|
sh 'bundle exec appraisal contrib-old rake spec:active_record'
|
224
224
|
sh 'bundle exec appraisal contrib-old rake spec:active_support'
|
225
225
|
sh 'bundle exec appraisal contrib-old rake spec:dalli'
|
226
|
+
sh 'bundle exec appraisal contrib-old rake spec:elasticsearch'
|
226
227
|
sh 'bundle exec appraisal contrib-old rake spec:excon'
|
227
228
|
sh 'bundle exec appraisal contrib-old rake spec:faraday'
|
228
229
|
sh 'bundle exec appraisal contrib-old rake spec:http'
|
@@ -264,6 +265,7 @@ task :ci do
|
|
264
265
|
sh 'bundle exec appraisal contrib-old rake spec:active_record'
|
265
266
|
sh 'bundle exec appraisal contrib-old rake spec:active_support'
|
266
267
|
sh 'bundle exec appraisal contrib-old rake spec:dalli'
|
268
|
+
sh 'bundle exec appraisal contrib-old rake spec:elasticsearch'
|
267
269
|
sh 'bundle exec appraisal contrib-old rake spec:excon'
|
268
270
|
sh 'bundle exec appraisal contrib-old rake spec:faraday'
|
269
271
|
sh 'bundle exec appraisal contrib-old rake spec:http'
|
@@ -308,6 +310,7 @@ task :ci do
|
|
308
310
|
sh 'bundle exec appraisal contrib-old rake spec:active_record'
|
309
311
|
sh 'bundle exec appraisal contrib-old rake spec:active_support'
|
310
312
|
sh 'bundle exec appraisal contrib-old rake spec:dalli'
|
313
|
+
sh 'bundle exec appraisal contrib-old rake spec:elasticsearch'
|
311
314
|
sh 'bundle exec appraisal contrib-old rake spec:excon'
|
312
315
|
sh 'bundle exec appraisal contrib-old rake spec:faraday'
|
313
316
|
sh 'bundle exec appraisal contrib-old rake spec:http'
|
@@ -358,6 +361,7 @@ task :ci do
|
|
358
361
|
sh 'bundle exec appraisal contrib rake spec:active_record'
|
359
362
|
sh 'bundle exec appraisal contrib rake spec:active_support'
|
360
363
|
sh 'bundle exec appraisal contrib rake spec:dalli'
|
364
|
+
sh 'bundle exec appraisal contrib rake spec:elasticsearch'
|
361
365
|
sh 'bundle exec appraisal contrib rake spec:excon'
|
362
366
|
sh 'bundle exec appraisal contrib rake spec:faraday'
|
363
367
|
sh 'bundle exec appraisal contrib rake spec:graphql'
|
@@ -420,6 +424,7 @@ task :ci do
|
|
420
424
|
sh 'bundle exec appraisal contrib rake spec:active_support'
|
421
425
|
sh 'bundle exec appraisal contrib rake spec:dalli'
|
422
426
|
sh 'bundle exec appraisal contrib rake spec:excon'
|
427
|
+
sh 'bundle exec appraisal contrib rake spec:elasticsearch'
|
423
428
|
sh 'bundle exec appraisal contrib rake spec:faraday'
|
424
429
|
sh 'bundle exec appraisal contrib rake spec:graphql'
|
425
430
|
sh 'bundle exec appraisal contrib rake spec:grpc'
|
@@ -479,6 +484,7 @@ task :ci do
|
|
479
484
|
sh 'bundle exec appraisal contrib rake spec:active_record'
|
480
485
|
sh 'bundle exec appraisal contrib rake spec:active_support'
|
481
486
|
sh 'bundle exec appraisal contrib rake spec:dalli'
|
487
|
+
sh 'bundle exec appraisal contrib rake spec:elasticsearch'
|
482
488
|
sh 'bundle exec appraisal contrib rake spec:excon'
|
483
489
|
sh 'bundle exec appraisal contrib rake spec:faraday'
|
484
490
|
sh 'bundle exec appraisal contrib rake spec:graphql'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
production:
|
2
|
+
adapter: 'postgresql'
|
3
|
+
timeout: 5000
|
4
|
+
database: <%= ENV.fetch('TEST_POSTGRES_DB', 'postgres') %>
|
5
|
+
host: <%= ENV.fetch('TEST_POSTGRES_HOST', '127.0.0.1') %>
|
6
|
+
port: <%= ENV.fetch('TEST_POSTGRES_PORT', 5432) %>
|
7
|
+
username: <%= ENV.fetch('TEST_POSTGRES_USER', 'postgres') %>
|
8
|
+
password: <%= ENV.fetch('TEST_POSTGRES_PASSWORD', 'postgres') %>
|
9
|
+
pool: 30
|
@@ -0,0 +1,154 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'production'
|
2
|
+
require 'English'
|
3
|
+
|
4
|
+
# Benchmark Configuration container
|
5
|
+
module TestConfiguration
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def sidekiq
|
9
|
+
Sidekiq.options.tap do |options|
|
10
|
+
options[:tag] = 'test'
|
11
|
+
options[:queues] << 'default'
|
12
|
+
options[:concurrency] = 20
|
13
|
+
options[:timeout] = 2
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def redis
|
18
|
+
{ pool_size: 30, timeout: 3 }
|
19
|
+
end
|
20
|
+
|
21
|
+
def iteration_count
|
22
|
+
1000
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'bundler/setup'
|
27
|
+
require 'rails/all'
|
28
|
+
Bundler.require(*Rails.groups)
|
29
|
+
|
30
|
+
# Example Rails App
|
31
|
+
module SampleApp
|
32
|
+
class Application < Rails::Application; end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Overrides rails configueration locations
|
36
|
+
module OverrideConfiguration
|
37
|
+
def paths
|
38
|
+
super.tap { |path| path.add 'config/database', with: 'benchmarks/postgres_database.yml' }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Rails::Application::Configuration.prepend(OverrideConfiguration)
|
43
|
+
|
44
|
+
Rails.application.configure do
|
45
|
+
config.cache_classes = true
|
46
|
+
config.eager_load = true
|
47
|
+
config.active_job.queue_adapter = :sidekiq
|
48
|
+
end
|
49
|
+
|
50
|
+
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
|
51
|
+
Rails.application.initialize!
|
52
|
+
|
53
|
+
ActiveRecord::Schema.define do
|
54
|
+
drop_table(:samples) if connection.table_exists?(:samples)
|
55
|
+
|
56
|
+
create_table :samples do |t|
|
57
|
+
t.string :name
|
58
|
+
t.timestamps
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Sample < ActiveRecord::Base; end
|
63
|
+
|
64
|
+
require 'sidekiq/launcher'
|
65
|
+
require 'sidekiq/cli'
|
66
|
+
require 'concurrent/atomic/atomic_fixnum'
|
67
|
+
|
68
|
+
Sidekiq.configure_server do |config|
|
69
|
+
redis_conn = proc do
|
70
|
+
Redis.new(
|
71
|
+
host: ENV.fetch('TEST_REDIS_HOST', '127.0.0.1'),
|
72
|
+
port: ENV.fetch('TEST_REDIS_PORT', 6379)
|
73
|
+
)
|
74
|
+
end
|
75
|
+
config.redis = ConnectionPool.new(size: TestConfiguration.redis[:pool_size],
|
76
|
+
timeout: TestConfiguration.redis[:timeout],
|
77
|
+
&redis_conn)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Simple Sidekiq worker performing the real benchmark
|
81
|
+
class Worker
|
82
|
+
class << self
|
83
|
+
attr_reader :iterations, :conditional_variable
|
84
|
+
end
|
85
|
+
|
86
|
+
@iterations = Concurrent::AtomicFixnum.new(0)
|
87
|
+
@conditional_variable = ConditionVariable.new
|
88
|
+
|
89
|
+
include Sidekiq::Worker
|
90
|
+
def perform(iter, max_iterations)
|
91
|
+
self.class.iterations.increment
|
92
|
+
self.class.conditional_variable.broadcast if self.class.iterations.value > max_iterations
|
93
|
+
|
94
|
+
Sample.create!(name: iter.to_s).save
|
95
|
+
|
96
|
+
100.times do
|
97
|
+
Sample.last.name
|
98
|
+
end
|
99
|
+
|
100
|
+
Sample.last(100).to_a
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
if Datadog.respond_to?(:configure)
|
105
|
+
Datadog.configure do |d|
|
106
|
+
d.use :rails, enabled: true, tags: { 'tag' => 'value' }
|
107
|
+
d.use :http
|
108
|
+
d.use :sidekiq, service_name: 'service'
|
109
|
+
d.use :redis
|
110
|
+
d.use :dalli
|
111
|
+
d.use :resque, workers: [Worker]
|
112
|
+
|
113
|
+
processor = Datadog::Pipeline::SpanProcessor.new do |span|
|
114
|
+
true if span.service == 'B'
|
115
|
+
end
|
116
|
+
|
117
|
+
Datadog::Pipeline.before_flush(processor)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def current_memory
|
122
|
+
`ps -o rss #{$PROCESS_ID}`.split("\n")[1].to_f / 1024
|
123
|
+
end
|
124
|
+
|
125
|
+
def time
|
126
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
127
|
+
end
|
128
|
+
|
129
|
+
def launch(iterations, options)
|
130
|
+
iterations.times do |i|
|
131
|
+
Worker.perform_async(i, iterations)
|
132
|
+
end
|
133
|
+
|
134
|
+
launcher = Sidekiq::Launcher.new(options)
|
135
|
+
launcher.run
|
136
|
+
end
|
137
|
+
|
138
|
+
def wait_and_measure(iterations)
|
139
|
+
start = time
|
140
|
+
|
141
|
+
STDERR.puts "#{time - start}, #{current_memory}"
|
142
|
+
|
143
|
+
mutex = Mutex.new
|
144
|
+
|
145
|
+
while Worker.iterations.value < iterations
|
146
|
+
mutex.synchronize do
|
147
|
+
Worker.conditional_variable.wait(mutex, 1)
|
148
|
+
STDERR.puts "#{time - start}, #{current_memory}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
launch(TestConfiguration.iteration_count, TestConfiguration.sidekiq)
|
154
|
+
wait_and_measure(TestConfiguration.iteration_count)
|
data/ddtrace.gemspec
CHANGED
@@ -43,6 +43,9 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_development_dependency 'yard', '~> 0.9'
|
44
44
|
spec.add_development_dependency 'webmock', '~> 2.0'
|
45
45
|
spec.add_development_dependency 'builder'
|
46
|
+
spec.add_development_dependency 'ruby-prof'
|
47
|
+
spec.add_development_dependency 'sqlite3'
|
48
|
+
|
46
49
|
# locking transitive dependency of webmock
|
47
50
|
spec.add_development_dependency 'addressable', '~> 2.4.0'
|
48
51
|
spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
|
data/docs/GettingStarted.md
CHANGED
@@ -33,6 +33,7 @@ For descriptions of terminology used in APM, take a look at the [official docume
|
|
33
33
|
- [Grape](#grape)
|
34
34
|
- [GraphQL](#graphql)
|
35
35
|
- [MongoDB](#mongodb)
|
36
|
+
- [MySQL2](#mysql2)
|
36
37
|
- [Net/HTTP](#nethttp)
|
37
38
|
- [Racecar](#racecar)
|
38
39
|
- [Rack](#rack)
|
@@ -96,7 +97,7 @@ The Ruby APM tracer sends trace data through the Datadog Agent.
|
|
96
97
|
### Quickstart for Rails applications
|
97
98
|
|
98
99
|
1. Add the `ddtrace` gem to your Gemfile:
|
99
|
-
|
100
|
+
|
100
101
|
```ruby
|
101
102
|
source 'https://rubygems.org'
|
102
103
|
gem 'ddtrace'
|
@@ -228,11 +229,11 @@ end
|
|
228
229
|
```
|
229
230
|
#####Enriching traces from nested methods
|
230
231
|
|
231
|
-
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.
|
232
|
+
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.
|
232
233
|
|
233
234
|
```ruby
|
234
235
|
# e.g. adding tag to active span
|
235
|
-
|
236
|
+
|
236
237
|
current_span = Datadog.tracer.active_span
|
237
238
|
current_span.set_tag('my_tag', 'my_value') unless current_span.nil?
|
238
239
|
```
|
@@ -264,6 +265,7 @@ For a list of available integrations, and their configuration options, please re
|
|
264
265
|
| Grape | `grape` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
|
265
266
|
| GraphQL | `graphql` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
|
266
267
|
| MongoDB | `mongo` | `>= 2.0, < 2.5` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
|
268
|
+
| MySQL2 | `mysql2` | `>= 0.5` | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
|
267
269
|
| Net/HTTP | `http` | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
|
268
270
|
| Racecar | `racecar` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
|
269
271
|
| Rack | `rack` | `>= 1.4.7` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
|
@@ -455,7 +457,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
455
457
|
|
456
458
|
### gRPC
|
457
459
|
|
458
|
-
The `grpc` integration adds both client and server interceptors, which run as middleware prior to executing the service's remote procedure call. As gRPC applications are often distributed, the integration shares trace information between client and server.
|
460
|
+
The `grpc` integration adds both client and server interceptors, which run as middleware prior to executing the service's remote procedure call. As gRPC applications are often distributed, the integration shares trace information between client and server.
|
459
461
|
|
460
462
|
To setup your integration, use the ``Datadog.configure`` method like so:
|
461
463
|
|
@@ -613,6 +615,29 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
613
615
|
| ``service_name`` | Service name used for `mongo` instrumentation | mongodb |
|
614
616
|
| ``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] }``` |
|
615
617
|
|
618
|
+
### MySQL2
|
619
|
+
|
620
|
+
The MySQL2 integration traces any SQL command sent through `mysql2` gem.
|
621
|
+
|
622
|
+
```ruby
|
623
|
+
require 'mysql2'
|
624
|
+
require 'ddtrace'
|
625
|
+
|
626
|
+
Datadog.configure do |c|
|
627
|
+
c.use :mysql2, options
|
628
|
+
end
|
629
|
+
|
630
|
+
client = Mysql2::Client.new(:host => "localhost", :username => "root")
|
631
|
+
client.query("SELECT * FROM users WHERE group='x'")
|
632
|
+
```
|
633
|
+
|
634
|
+
Where `options` is an optional `Hash` that accepts the following parameters:
|
635
|
+
|
636
|
+
| Key | Description | Default |
|
637
|
+
| --- | --- | --- |
|
638
|
+
| ``service_name`` | Service name used for MySQL2 instrumentation | `mysql2` |
|
639
|
+
| ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
|
640
|
+
|
616
641
|
### Net/HTTP
|
617
642
|
|
618
643
|
The Net/HTTP integration will trace any HTTP call using the standard lib Net::HTTP module.
|
@@ -759,7 +784,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
759
784
|
| Key | Description | Default |
|
760
785
|
| --- | --- | --- |
|
761
786
|
| ``service_name`` | Service name used when tracing application requests (on the `rack` level) | ``<app_name>`` (inferred from your Rails application namespace) |
|
762
|
-
| ``controller_service`` | Service name used when tracing a Rails action controller | ``<app_name
|
787
|
+
| ``controller_service`` | Service name used when tracing a Rails action controller | ``<app_name>`` |
|
763
788
|
| ``cache_service`` | Cache service name used when tracing cache activity | ``<app_name>-cache`` |
|
764
789
|
| ``database_service`` | Database service name used when tracing database activity | ``<app_name>-<adapter_name>`` |
|
765
790
|
| ``exception_controller`` | Class or Module which identifies a custom exception controller class. Tracer provides improved error behavior when it can identify custom exception controllers. By default, without this option, it 'guesses' what a custom exception controller looks like. Providing this option aids this identification. | ``nil`` |
|
data/lib/ddtrace.rb
CHANGED
@@ -14,6 +14,7 @@ require 'ddtrace/patcher'
|
|
14
14
|
module Datadog
|
15
15
|
@tracer = Tracer.new
|
16
16
|
@registry = Registry.new
|
17
|
+
@configuration = Configuration.new(registry: @registry)
|
17
18
|
|
18
19
|
# Default tracer that can be used as soon as +ddtrace+ is required:
|
19
20
|
#
|
@@ -28,21 +29,9 @@ module Datadog
|
|
28
29
|
# tracer = Datadog::Tracer.new
|
29
30
|
# pin = Datadog::Pin.get_from(mypatchcomponent)
|
30
31
|
# pin.tracer = tracer
|
31
|
-
|
32
|
-
def self.tracer
|
33
|
-
@tracer
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.registry
|
37
|
-
@registry
|
38
|
-
end
|
39
|
-
|
40
32
|
class << self
|
41
|
-
|
42
|
-
|
43
|
-
def configuration
|
44
|
-
@configuration ||= Configuration.new
|
45
|
-
end
|
33
|
+
attr_reader :tracer, :registry
|
34
|
+
attr_accessor :configuration
|
46
35
|
|
47
36
|
def configure(target = configuration, opts = {})
|
48
37
|
if target.is_a?(Configuration)
|
@@ -75,11 +75,12 @@ module Datadog
|
|
75
75
|
tracer.trace(@span_name, @options).tap do |span|
|
76
76
|
# Assign start time if provided
|
77
77
|
span.start_time = start unless start.nil?
|
78
|
+
payload[:datadog_span] = span
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
81
82
|
def finish_span(name, id, payload, finish = nil)
|
82
|
-
|
83
|
+
payload[:datadog_span].tap do |span|
|
83
84
|
# If no active span, return.
|
84
85
|
return nil if span.nil?
|
85
86
|
|
data/lib/ddtrace/version.rb
CHANGED
data/lib/ddtrace/workers.rb
CHANGED
@@ -43,7 +43,7 @@ module Datadog
|
|
43
43
|
# ensures that the thread will not die because of an exception.
|
44
44
|
# TODO[manu]: findout the reason and reschedule the send if it's not
|
45
45
|
# a fatal exception
|
46
|
-
Datadog::Tracer.log.error("Error during traces flush: dropped #{
|
46
|
+
Datadog::Tracer.log.error("Error during traces flush: dropped #{traces.length} items. Cause: #{e}")
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -58,7 +58,7 @@ module Datadog
|
|
58
58
|
# ensures that the thread will not die because of an exception.
|
59
59
|
# TODO[manu]: findout the reason and reschedule the send if it's not
|
60
60
|
# a fatal exception
|
61
|
-
Datadog::Tracer.log.error("Error during services flush: dropped #{
|
61
|
+
Datadog::Tracer.log.error("Error during services flush: dropped #{services.length} items. Cause: #{e}")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -106,15 +106,17 @@ module Datadog
|
|
106
106
|
|
107
107
|
private
|
108
108
|
|
109
|
+
alias flush_data callback_traces
|
110
|
+
|
109
111
|
def perform
|
110
112
|
loop do
|
111
|
-
@back_off =
|
113
|
+
@back_off = flush_data ? @flush_interval : [@back_off * BACK_OFF_RATIO, BACK_OFF_MAX].min
|
112
114
|
|
113
115
|
callback_services
|
114
116
|
|
115
117
|
@mutex.synchronize do
|
116
118
|
return if !@run && @trace_buffer.empty? && @service_buffer.empty?
|
117
|
-
@shutdown.wait(@mutex, @back_off)
|
119
|
+
@shutdown.wait(@mutex, @back_off) if @run # do not wait when shutting down
|
118
120
|
end
|
119
121
|
end
|
120
122
|
end
|
data/lib/ddtrace/writer.rb
CHANGED
@@ -7,7 +7,7 @@ module Datadog
|
|
7
7
|
class Writer
|
8
8
|
attr_reader :transport, :worker, :priority_sampler
|
9
9
|
|
10
|
-
HOSTNAME = '
|
10
|
+
HOSTNAME = '127.0.0.1'.freeze
|
11
11
|
PORT = '8126'.freeze
|
12
12
|
|
13
13
|
def initialize(options = {})
|
@@ -15,7 +15,6 @@ module Datadog
|
|
15
15
|
@buff_size = options.fetch(:buffer_size, 100)
|
16
16
|
@flush_interval = options.fetch(:flush_interval, 1)
|
17
17
|
transport_options = options.fetch(:transport_options, {})
|
18
|
-
|
19
18
|
# priority sampling
|
20
19
|
if options[:priority_sampler]
|
21
20
|
@priority_sampler = options[:priority_sampler]
|
@@ -95,10 +94,10 @@ module Datadog
|
|
95
94
|
# This check ensures that if a process doesn't own the current +Writer+, async workers
|
96
95
|
# will be initialized again (but only once for each process).
|
97
96
|
pid = Process.pid
|
98
|
-
@
|
99
|
-
|
97
|
+
if pid != @pid # avoid using Mutex when pids are equal
|
98
|
+
@mutex_after_fork.synchronize do
|
100
99
|
# we should start threads because the worker doesn't own this
|
101
|
-
start
|
100
|
+
start if pid != @pid
|
102
101
|
end
|
103
102
|
end
|
104
103
|
|
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.13.
|
4
|
+
version: 0.13.1
|
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-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -150,6 +150,34 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ruby-prof
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sqlite3
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: addressable
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,6 +263,8 @@ files:
|
|
235
263
|
- LICENSE
|
236
264
|
- README.md
|
237
265
|
- Rakefile
|
266
|
+
- benchmarks/postgres_database.yml
|
267
|
+
- benchmarks/sidekiq_test.rb
|
238
268
|
- ddtrace.gemspec
|
239
269
|
- docker-compose.yml
|
240
270
|
- docs/GettingStarted.md
|