ddtrace 0.19.0 → 0.19.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f812f568118b7998a52208ffdb4c90a253edfd67
4
- data.tar.gz: 914ce035245993d7535152437c720c8c3cca3c2e
3
+ metadata.gz: 52ce2b14a7143fb0f53beba225ad73d018397eb7
4
+ data.tar.gz: 793d9001870488465a243c87d1476db4f73a299d
5
5
  SHA512:
6
- metadata.gz: '08f6d5fe32d68feb4c38ef89ef43908c76884d1b92b30929fc3edd7c50fad58674d21f7e00ff97e4731b008213e9e0584106691d52ed8b1feb16b0dbdac877a0'
7
- data.tar.gz: 8b452ada6e2cfb91d1ee170600dc3fc7cd17c0b37042c6a3a746cc5739da038b37457204194f8ecdbc802a85d5afcdb4e79d13bf31293c2226aa0d62dcd0fa66
6
+ metadata.gz: 7f80807b947c9130e3946b260065af504f77759af8b883f4ec3e3dda3d5f0df24a33faf4ca7ae3b3d73b29c2ee62272982f1408c244aea2048640158964a3f61
7
+ data.tar.gz: dc887bb9c6f66ed29cd5176f9d82be384c0d089ff9413d600e8c8e5b8ca410124cf5d0ec2da9cc296c23e181828be5f3b235d593176235a4ccca5c2b78481a7d
data/Appraisals CHANGED
@@ -86,7 +86,7 @@ elsif Gem::Version.new('1.9.3') <= Gem::Version.new(RUBY_VERSION) \
86
86
  gem 'sequel', '~> 4.0', '< 4.37'
87
87
  gem 'sidekiq', '~> 3.5.4'
88
88
  gem 'sinatra', '1.4.5'
89
- gem 'sqlite3'
89
+ gem 'sqlite3', '~> 1.3.6'
90
90
  gem 'sucker_punch'
91
91
  gem 'timers', '< 4.2'
92
92
  end
@@ -171,7 +171,7 @@ elsif Gem::Version.new('2.0.0') <= Gem::Version.new(RUBY_VERSION) \
171
171
  gem 'sequel', '~> 4.0', '< 4.37'
172
172
  gem 'sidekiq', '~> 3.5.4'
173
173
  gem 'sinatra', '1.4.5'
174
- gem 'sqlite3'
174
+ gem 'sqlite3', '~> 1.3.6'
175
175
  gem 'sucker_punch'
176
176
  gem 'timers', '< 4.2'
177
177
  end
@@ -277,7 +277,7 @@ elsif Gem::Version.new('2.1.0') <= Gem::Version.new(RUBY_VERSION) \
277
277
  gem 'shoryuken'
278
278
  gem 'sidekiq', '~> 3.5.4'
279
279
  gem 'sinatra', '1.4.5'
280
- gem 'sqlite3'
280
+ gem 'sqlite3', '~> 1.3.6'
281
281
  gem 'sucker_punch'
282
282
  gem 'timers', '< 4.2'
283
283
  end
@@ -417,7 +417,7 @@ elsif Gem::Version.new('2.2.0') <= Gem::Version.new(RUBY_VERSION) \
417
417
  gem 'shoryuken'
418
418
  gem 'sidekiq'
419
419
  gem 'sinatra'
420
- gem 'sqlite3'
420
+ gem 'sqlite3', '~> 1.3.6'
421
421
  gem 'sucker_punch'
422
422
  end
423
423
  end
@@ -556,7 +556,7 @@ elsif Gem::Version.new('2.3.0') <= Gem::Version.new(RUBY_VERSION) \
556
556
  gem 'shoryuken'
557
557
  gem 'sidekiq'
558
558
  gem 'sinatra'
559
- gem 'sqlite3'
559
+ gem 'sqlite3', '~> 1.3.6'
560
560
  gem 'sucker_punch'
561
561
  end
562
562
  end
@@ -589,7 +589,7 @@ elsif Gem::Version.new('2.4.0') <= Gem::Version.new(RUBY_VERSION)
589
589
  gem 'shoryuken'
590
590
  gem 'sidekiq'
591
591
  gem 'sinatra'
592
- gem 'sqlite3'
592
+ gem 'sqlite3', '~> 1.3.6'
593
593
  gem 'sucker_punch'
594
594
  end
595
595
  end
data/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@
4
4
 
5
5
  ## [Unreleased (beta)]
6
6
 
7
+ ## [0.19.1] - 2019-02-07
8
+
9
+ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.19.1
10
+
11
+ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.19.0...v0.19.1
12
+
13
+ ### Added
14
+
15
+ - Documentation for Lograge implementation (#683, #687) (@nic-lan)
16
+
17
+ ### Fixed
18
+
19
+ - Priority sampling dropping spans (#686)
20
+
7
21
  ## [0.19.0] - 2019-01-22
8
22
 
9
23
  Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.19.0
@@ -12,12 +26,12 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.18.3...v0.19.0
12
26
 
13
27
  ### Added
14
28
 
15
- - Tracer#active_correlation for adding correlation IDs to logs. (#660, #664, #673)
16
- - Opt-in support for `event_sample_rate` tag for some integrations. (#665, #666)
29
+ - Tracer#active_correlation for adding correlation IDs to logs. (#660, #664, #673)
30
+ - Opt-in support for `event_sample_rate` tag for some integrations. (#665, #666)
17
31
 
18
32
  ### Changed
19
33
 
20
- - Priority sampling enabled by default. (#654)
34
+ - Priority sampling enabled by default. (#654)
21
35
 
22
36
  ## [0.18.3] - 2019-01-17
23
37
 
@@ -60,15 +74,15 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.17.3...v0.18.0
60
74
 
61
75
  ### Added
62
76
 
63
- - Shoryuken integration (#538, #626, #655) (@steveh, @JustSnow)
64
- - Sidekiq client integration (#602, #650) (@dirk)
65
- - Datadog::Shim for adding instrumentation (#648)
77
+ - Shoryuken integration (#538, #626, #655) (@steveh, @JustSnow)
78
+ - Sidekiq client integration (#602, #650) (@dirk)
79
+ - Datadog::Shim for adding instrumentation (#648)
66
80
 
67
81
  ### Changed
68
82
 
69
- - Use `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT` env vars if available (#631)
70
- - Inject `:connection` into `sql.active_record` event (#640, #649, #656) (@guizmaii)
71
- - Return default configuration instead of `nil` on miss (#651)
83
+ - Use `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT` env vars if available (#631)
84
+ - Inject `:connection` into `sql.active_record` event (#640, #649, #656) (@guizmaii)
85
+ - Return default configuration instead of `nil` on miss (#651)
72
86
 
73
87
  ## [0.17.3] - 2018-11-29
74
88
 
@@ -111,18 +125,18 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.16.1...v0.17.0
111
125
 
112
126
  ### Added
113
127
 
114
- - [BETA] Span memory `allocations` attribute (#597) (@dasch)
128
+ - [BETA] Span memory `allocations` attribute (#597) (@dasch)
115
129
 
116
130
  ### Changed
117
131
 
118
- - Use Rack Env to update resource in Rails (#580) (@dasch)
119
- - Expand support for Sidekiq to 3.5.4+ (#593)
120
- - Expand support for mysql2 to 0.3.21+ (#578)
132
+ - Use Rack Env to update resource in Rails (#580) (@dasch)
133
+ - Expand support for Sidekiq to 3.5.4+ (#593)
134
+ - Expand support for mysql2 to 0.3.21+ (#578)
121
135
 
122
136
  ### Refactored
123
137
 
124
- - Upgraded integrations to new API (#544)
125
- - Encoding classes into modules (#598)
138
+ - Upgraded integrations to new API (#544)
139
+ - Encoding classes into modules (#598)
126
140
 
127
141
  ## [0.16.1] - 2018-10-17
128
142
 
@@ -266,7 +280,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.13.1...v0.13.2
266
280
 
267
281
  ### Fixed
268
282
 
269
- - Context propagation for distributed traces when context is full (#502)
283
+ - Context propagation for distributed traces when context is full (#502)
270
284
 
271
285
  ## [0.13.1] - 2018-07-17
272
286
 
@@ -276,15 +290,15 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.13.0...v0.13.1
276
290
 
277
291
  ### Changed
278
292
 
279
- - Configuration class variables don't lazy load (#477)
280
- - Default tracer host `localhost` --> `127.0.0.1` (#466, #480) (@NobodysNightmare)
293
+ - Configuration class variables don't lazy load (#477)
294
+ - Default tracer host `localhost` --> `127.0.0.1` (#466, #480) (@NobodysNightmare)
281
295
 
282
296
  ### Fixed
283
297
 
284
- - Workers not shutting down quickly in some short running processes (#475)
285
- - Missing documentation for mysql2 and Rails (#476, #488)
286
- - Missing variable in rescue block (#481) (@kitop)
287
- - Unclosed spans in ActiveSupport::Notifications with multithreading (#431, #478) (@senny)
298
+ - Workers not shutting down quickly in some short running processes (#475)
299
+ - Missing documentation for mysql2 and Rails (#476, #488)
300
+ - Missing variable in rescue block (#481) (@kitop)
301
+ - Unclosed spans in ActiveSupport::Notifications with multithreading (#431, #478) (@senny)
288
302
 
289
303
  ## [0.13.0] - 2018-06-20
290
304
 
@@ -327,6 +341,7 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.13.0.beta1
327
341
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0...v0.13.0.beta1
328
342
 
329
343
  ### Added
344
+
330
345
  - Sequel integration (supporting Ruby 2.0+) (#171, #367) (@randy-girard, @twe4ked, @palin)
331
346
  - gRPC integration (supporting Ruby 2.2+) (#379, #403) (@Jared-Prime)
332
347
  - ActiveModelSerializers integration (#340) (@sullimander)
@@ -337,6 +352,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0...v0.13.0.beta1
337
352
  - Request and response header tags to Rack (#389)
338
353
 
339
354
  ### Refactored
355
+
340
356
  - Hash quantization into core library (#410)
341
357
 
342
358
  ## [0.12.1] - 2018-06-12
@@ -346,20 +362,23 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.12.1
346
362
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0...v0.12.1
347
363
 
348
364
  ### Changed
349
- - Cache configuration `Proxy` objects (#446)
350
- - `freeze` more constant strings, to improve memory usage (#446)
365
+
366
+ - Cache configuration `Proxy` objects (#446)
367
+ - `freeze` more constant strings, to improve memory usage (#446)
351
368
  - `Utils#truncate` to use slightly less memory (#446)
352
369
 
353
370
  ### Fixed
354
- - Net/HTTP integration not permitting `service_name` to be overridden. (#407, #430) (@undergroundwebdesigns)
355
- - Block not being passed through Elasticsearch client initialization. (#421) (@shayonj)
356
- - Devise raising `NoMethodError` when bad login attempts are made. (#419, #420) (@frsantos)
357
- - AWS spans using wrong resource name (#374, #377) (@jfrancoist)
358
- - ActionView `NoMethodError` on very long traces. (#445, #447) (@jvalanen)
371
+
372
+ - Net/HTTP integration not permitting `service_name` to be overridden. (#407, #430) (@undergroundwebdesigns)
373
+ - Block not being passed through Elasticsearch client initialization. (#421) (@shayonj)
374
+ - Devise raising `NoMethodError` when bad login attempts are made. (#419, #420) (@frsantos)
375
+ - AWS spans using wrong resource name (#374, #377) (@jfrancoist)
376
+ - ActionView `NoMethodError` on very long traces. (#445, #447) (@jvalanen)
359
377
 
360
378
  ### Refactored
361
- - ActionController patching strategy using modules. (#439)
362
- - ActionView tracing strategy. (#445, #447)
379
+
380
+ - ActionController patching strategy using modules. (#439)
381
+ - ActionView tracing strategy. (#445, #447)
363
382
 
364
383
  ## [0.12.0] - 2018-05-08
365
384
 
@@ -368,6 +387,7 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.12.0
368
387
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.4...v0.12.0
369
388
 
370
389
  ### Added
390
+
371
391
  - GraphQL integration (supporting graphql 1.7.9+) (#295)
372
392
  - ActiveRecord object instantiation tracing (#311, #334)
373
393
  - Subscriber module for ActiveSupport::Notifications tracing (#324, #380, #390, #395) (@dasch)
@@ -375,20 +395,24 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.4...v0.12.0
375
395
  - Partial flushing option to tracer (#247, #397)
376
396
 
377
397
  ### Changed
398
+
378
399
  - Rack applies URL quantization by default (#371)
379
400
  - Elasticsearch applies body quantization by default (#362)
380
401
  - Context for a single trace now has hard limit of 100,000 spans (#247)
381
402
  - Tags with `rails.db.x` to `active_record.db.x` instead (#396)
382
403
 
383
404
  ### Fixed
405
+
384
406
  - Loading the ddtrace library after Rails has fully initialized can result in load errors. (#357)
385
407
  - Some scenarios where `middleware_names` could result in bad resource names (#354)
386
408
  - ActionController instrumentation conflicting with some gems that monkey patch Rails (#391)
387
409
 
388
410
  ### Deprecated
411
+
389
412
  - Use of `:datadog_rack_request_span` variable in favor of `'datadog.rack_request_span'` in Rack. (#365, #392)
390
413
 
391
414
  ### Refactored
415
+
392
416
  - Racecar to use ActiveSupport::Notifications Subscriber module (#381)
393
417
  - Rails to use ActiveRecord integration instead of its own implementation (#396)
394
418
  - ActiveRecord to use ActiveSupport::Notifications Subscriber module (#396)
@@ -400,6 +424,7 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.12.0.rc1
400
424
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.4...v0.12.0.rc1
401
425
 
402
426
  ### Added
427
+
403
428
  - GraphQL integration (supporting graphql 1.7.9+) (#295)
404
429
  - ActiveRecord object instantiation tracing (#311, #334)
405
430
  - Subscriber module for ActiveSupport::Notifications tracing (#324, #380, #390, #395) (@dasch)
@@ -407,20 +432,24 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.4...v0.12.0.rc1
407
432
  - Partial flushing option to tracer (#247, #397)
408
433
 
409
434
  ### Changed
435
+
410
436
  - Rack applies URL quantization by default (#371)
411
437
  - Elasticsearch applies body quantization by default (#362)
412
438
  - Context for a single trace now has hard limit of 100,000 spans (#247)
413
439
  - Tags with `rails.db.x` to `active_record.db.x` instead (#396)
414
440
 
415
441
  ### Fixed
442
+
416
443
  - Loading the ddtrace library after Rails has fully initialized can result in load errors. (#357)
417
444
  - Some scenarios where `middleware_names` could result in bad resource names (#354)
418
445
  - ActionController instrumentation conflicting with some gems that monkey patch Rails (#391)
419
446
 
420
447
  ### Deprecated
448
+
421
449
  - Use of `:datadog_rack_request_span` variable in favor of `'datadog.rack_request_span'` in Rack. (#365, #392)
422
450
 
423
451
  ### Refactored
452
+
424
453
  - Racecar to use ActiveSupport::Notifications Subscriber module (#381)
425
454
  - Rails to use ActiveRecord integration instead of its own implementation (#396)
426
455
  - ActiveRecord to use ActiveSupport::Notifications Subscriber module (#396)
@@ -432,6 +461,7 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.12.0.beta2
432
461
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.12.0.beta1...v0.12.0.beta2
433
462
 
434
463
  ### Fixed
464
+
435
465
  - Loading the ddtrace library after Rails has fully initialized can result in load errors. (#357)
436
466
 
437
467
  ## [0.12.0.beta1] - 2018-02-09
@@ -441,6 +471,7 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.12.0.beta1
441
471
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.2...v0.12.0.beta1
442
472
 
443
473
  ### Added
474
+
444
475
  - GraphQL integration (supporting graphql 1.7.9+) (#295)
445
476
  - ActiveRecord object instantiation tracing (#311, #334)
446
477
  - `http.request_id` tag to Rack spans (#335)
@@ -452,6 +483,7 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.4
452
483
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.3...v0.11.4
453
484
 
454
485
  ### Fixed
486
+
455
487
  - Transport body parsing when downgrading (#369)
456
488
  - Transport incorrectly attempting to apply sampling to service metadata (#370)
457
489
  - `sql.active_record` traces showing incorrect adapter settings when non-default adapter used (#383)
@@ -463,11 +495,13 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.3
463
495
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.2...v0.11.3
464
496
 
465
497
  ### Added
498
+
466
499
  - CHANGELOG.md (#350, #363) (@awendt)
467
500
  - `http.request_id` tag to Rack spans (#335)
468
501
  - Tracer configuration to README.md (#332) (@noma4i)
469
502
 
470
503
  ### Fixed
504
+
471
505
  - Extra indentation in README.md (#349) (@ck3g)
472
506
  - `http.url` when Rails raises exceptions (#351, #353)
473
507
  - Rails from being patched twice (#352)
@@ -486,6 +520,7 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.2
486
520
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.1...v0.11.2
487
521
 
488
522
  ### Deprecated
523
+
489
524
  - `Datadog::Monkey` to be no-op and print deprecation warnings.
490
525
 
491
526
  ## [0.11.1] - 2018-01-29
@@ -495,18 +530,22 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.1
495
530
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.11.0...v0.11.1
496
531
 
497
532
  ### Added
533
+
498
534
  - `http.base_url` tag for Rack applications (#301, #327)
499
535
  - `distributed_tracing` option to Sinatra (#325)
500
536
  - `exception_controller` option to Rails (#320)
501
537
 
502
538
  ### Changed
539
+
503
540
  - Decoupled Sinatra and ActiveRecord integrations (#328, #330) (@hawknewton)
504
541
  - Racecar uses preferred ActiveSupport::Notifications strategy (#323)
505
542
 
506
543
  ### Removed
544
+
507
545
  - `Datadog::Monkey` in favor of newer configuration API (#322)
508
546
 
509
547
  ### Fixed
548
+
510
549
  - Custom resource names from Rails controllers being overridden (#321)
511
550
  - Custom Rails exception controllers reporting as the resource (#320)
512
551
 
@@ -642,8 +681,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
642
681
 
643
682
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
644
683
 
645
- [Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.0...master
646
- [Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.0...0.20-dev
684
+ [Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.1...master
685
+ [Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.1...0.20-dev
686
+ [0.19.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.0...v0.19.1
647
687
  [0.19.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.3...v0.19.0
648
688
  [0.18.3]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.2...v0.18.3
649
689
  [0.18.2]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.1...v0.18.2
data/ddtrace.gemspec CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency 'webmock', '~> 2.0'
47
47
  spec.add_development_dependency 'builder'
48
48
  spec.add_development_dependency 'ruby-prof'
49
- spec.add_development_dependency 'sqlite3'
49
+ spec.add_development_dependency 'sqlite3', '~> 1.3.6'
50
50
 
51
51
  # locking transitive dependency of webmock
52
52
  spec.add_development_dependency 'addressable', '~> 2.4.0'
@@ -1635,14 +1635,53 @@ correlation.trace_id # => 0
1635
1635
  correlation.span_id # => 0
1636
1636
  ```
1637
1637
 
1638
+ #### For logging in Rails applications using Lograge (recommended)
1639
+
1640
+ After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs:
1641
+
1642
+ ```ruby
1643
+ config.lograge.custom_options = lambda do |event|
1644
+ # Retrieves trace information for current thread
1645
+ correlation = Datadog.tracer.active_correlation
1646
+
1647
+ {
1648
+ # Adds IDs as tags to log output
1649
+ :dd => {
1650
+ :trace_id => correlation.trace_id,
1651
+ :span_id => correlation.span_id
1652
+ },
1653
+ :ddsource => ["ruby"],
1654
+ :params => event.payload[:params].reject { |k| %w(controller action).include? k }
1655
+ }
1656
+ end
1657
+ ```
1658
+
1659
+ #### For logging in Rails applications
1660
+
1661
+ Rails applications which are configured with a `ActiveSupport::TaggedLogging` logger can append correlation IDs as tags to log output. The default Rails logger implements this tagged logging, making it easier to add correlation tags.
1662
+
1663
+ In your Rails environment configuration file, add the following:
1664
+
1665
+ ```ruby
1666
+ Rails.application.configure do
1667
+ config.log_tags = [proc { Datadog.tracer.active_correlation.to_s }]
1668
+ end
1669
+
1670
+ # Web requests will produce:
1671
+ # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Started GET "/articles" for 172.22.0.1 at 2019-01-16 18:50:57 +0000
1672
+ # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Processing by ArticlesController#index as */*
1673
+ # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Article Load (0.5ms) SELECT "articles".* FROM "articles"
1674
+ # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Completed 200 OK in 7ms (Views: 5.5ms | ActiveRecord: 0.5ms)
1675
+ ```
1676
+
1638
1677
  #### For logging in Ruby applications
1639
1678
 
1640
1679
  To add correlation IDs to your logger, add a log formatter which retrieves the correlation IDs with `Datadog.tracer.active_correlation`, then add them to the message.
1641
1680
 
1642
- To properly correlate with Datadog logging, be sure the following is present:
1681
+ To properly correlate with Datadog logging, be sure the following is present in the log message:
1643
1682
 
1644
- - `dd.trace_id=<TRACE_ID>`: Where `<TRACE_ID>` is equal to `Datadog.tracer.active_correlation.trace_id` or `0` if no trace is active.
1645
- - `dd.span_id=<SPAN_ID>`: Where `<SPAN_ID>` is equal to `Datadog.tracer.active_correlation.span_id` or `0` if no trace is active.
1683
+ - `dd.trace_id=<TRACE_ID>`: Where `<TRACE_ID>` is equal to `Datadog.tracer.active_correlation.trace_id` or `0` if no trace is active during logging.
1684
+ - `dd.span_id=<SPAN_ID>`: Where `<SPAN_ID>` is equal to `Datadog.tracer.active_correlation.span_id` or `0` if no trace is active during logging.
1646
1685
 
1647
1686
  By default, `Datadog::Correlation::Identifier#to_s` will return `dd.trace_id=<TRACE_ID> dd.span_id=<SPAN_ID>`.
1648
1687
 
@@ -1667,24 +1706,6 @@ Datadog.tracer.trace('my.operation') { logger.warn('This is a traced operation.'
1667
1706
  # [2019-01-16 18:38:41 +0000][my_app][WARN][dd.trace_id=8545847825299552251 dd.span_id=3711755234730770098] This is a traced operation.
1668
1707
  ```
1669
1708
 
1670
- #### For logging in Rails applications
1671
-
1672
- Rails applications which are configured with a `ActiveSupport::TaggedLogging` logger can append correlation IDs as tags to log output. The default Rails logger implements this tagged logging, making it easier to add correlation tags.
1673
-
1674
- In your Rails environment configuration file, add the following:
1675
-
1676
- ```ruby
1677
- Rails.application.configure do
1678
- config.log_tags = [proc { Datadog.tracer.active_correlation.to_s }]
1679
- end
1680
-
1681
- # Web requests will produce:
1682
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Started GET "/articles" for 172.22.0.1 at 2019-01-16 18:50:57 +0000
1683
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Processing by ArticlesController#index as */*
1684
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Article Load (0.5ms) SELECT "articles".* FROM "articles"
1685
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Completed 200 OK in 7ms (Views: 5.5ms | ActiveRecord: 0.5ms)
1686
- ```
1687
-
1688
1709
  ### OpenTracing
1689
1710
 
1690
1711
  For setting up Datadog with OpenTracing, see out [Quickstart for OpenTracing](#quickstart-for-opentracing) section for details.
@@ -5,14 +5,22 @@ require 'ddtrace/ext/priority'
5
5
  module Datadog
6
6
  # \Sampler performs client-side trace sampling.
7
7
  class Sampler
8
- def sample(_span)
9
- raise NotImplementedError, 'samplers have to implement the sample() method'
8
+ def sample?(_span)
9
+ raise NotImplementedError, 'Samplers must implement the #sample? method'
10
+ end
11
+
12
+ def sample!(_span)
13
+ raise NotImplementedError, 'Samplers must implement the #sample! method'
10
14
  end
11
15
  end
12
16
 
13
17
  # \AllSampler samples all the traces.
14
18
  class AllSampler < Sampler
15
- def sample(span)
19
+ def sample?(span)
20
+ true
21
+ end
22
+
23
+ def sample!(span)
16
24
  span.sampled = true
17
25
  end
18
26
  end
@@ -20,7 +28,7 @@ module Datadog
20
28
  # \RateSampler is based on a sample rate.
21
29
  class RateSampler < Sampler
22
30
  KNUTH_FACTOR = 1111111111111111111
23
- SAMPLE_RATE_METRIC_KEY = '_sample_rate'.freeze()
31
+ SAMPLE_RATE_METRIC_KEY = '_sample_rate'.freeze
24
32
 
25
33
  attr_reader :sample_rate
26
34
 
@@ -45,9 +53,14 @@ module Datadog
45
53
  @sampling_id_threshold = sample_rate * Span::MAX_ID
46
54
  end
47
55
 
48
- def sample(span)
49
- span.set_metric(SAMPLE_RATE_METRIC_KEY, @sample_rate)
50
- span.sampled = ((span.trace_id * KNUTH_FACTOR) % Datadog::Span::MAX_ID) <= @sampling_id_threshold
56
+ def sample?(span)
57
+ ((span.trace_id * KNUTH_FACTOR) % Datadog::Span::MAX_ID) <= @sampling_id_threshold
58
+ end
59
+
60
+ def sample!(span)
61
+ (span.sampled = sample?(span)).tap do |sampled|
62
+ span.set_metric(SAMPLE_RATE_METRIC_KEY, @sample_rate) if sampled
63
+ end
51
64
  end
52
65
  end
53
66
 
@@ -62,11 +75,27 @@ module Datadog
62
75
  @sampler = { DEFAULT_KEY => @fallback }
63
76
  end
64
77
 
65
- def sample(span)
78
+ def sample?(span)
66
79
  key = key_for(span)
67
80
 
68
81
  @mutex.synchronize do
69
- @sampler.fetch(key, @fallback).sample(span)
82
+ @sampler.fetch(key, @fallback).sample?(span)
83
+ end
84
+ end
85
+
86
+ def sample!(span)
87
+ key = key_for(span)
88
+
89
+ @mutex.synchronize do
90
+ @sampler.fetch(key, @fallback).sample!(span)
91
+ end
92
+ end
93
+
94
+ def sample_rate(span)
95
+ key = key_for(span)
96
+
97
+ @mutex.synchronize do
98
+ @sampler.fetch(key, @fallback).sample_rate
70
99
  end
71
100
  end
72
101
 
@@ -92,38 +121,75 @@ module Datadog
92
121
  class PrioritySampler
93
122
  extend Forwardable
94
123
 
124
+ SAMPLE_RATE_METRIC_KEY = '_sample_rate'.freeze
125
+
95
126
  def initialize(opts = {})
96
- @base_sampler = opts[:base_sampler] || RateSampler.new
97
- @post_sampler = opts[:post_sampler] || RateByServiceSampler.new
127
+ @pre_sampler = opts[:base_sampler] || AllSampler.new
128
+ @priority_sampler = opts[:post_sampler] || RateByServiceSampler.new
98
129
  end
99
130
 
100
- def sample(span)
101
- return perform_sampling(span) unless span.context
102
- return sampled_by_upstream(span) if span.context.sampling_priority
131
+ def sample?(span)
132
+ @pre_sampler.sample?(span)
133
+ end
103
134
 
104
- perform_sampling(span).tap do |sampled|
105
- span.context.sampling_priority = if sampled
106
- Datadog::Ext::Priority::AUTO_KEEP
107
- else
108
- Datadog::Ext::Priority::AUTO_REJECT
109
- end
135
+ def sample!(span)
136
+ # If pre-sampling is configured, do it first. (By default, this will sample at 100%.)
137
+ # NOTE: Pre-sampling at rates < 100% may result in partial traces; not recommended.
138
+ span.sampled = pre_sample?(span) ? @pre_sampler.sample!(span) : true
139
+
140
+ if span.sampled
141
+ # If priority sampling has already been applied upstream, use that, otherwise...
142
+ unless priority_assigned_upstream?(span)
143
+ # Roll the dice and determine whether how we set the priority.
144
+ # NOTE: We'll want to leave `span.sampled = true` here; all spans for priority sampling must
145
+ # be sent to the agent. Otherwise metrics for traces will not be accurate, since the
146
+ # agent will have an incomplete dataset.
147
+ priority = priority_sample(span) ? Datadog::Ext::Priority::AUTO_KEEP : Datadog::Ext::Priority::AUTO_REJECT
148
+ assign_priority!(span, priority)
149
+ end
150
+ else
151
+ # If discarded by pre-sampling, set "reject" priority, so other
152
+ # services for the same trace don't sample needlessly.
153
+ assign_priority!(span, Datadog::Ext::Priority::AUTO_REJECT)
110
154
  end
155
+
156
+ span.sampled
111
157
  end
112
158
 
113
- def_delegators :@post_sampler, :update
159
+ def_delegators :@priority_sampler, :update
114
160
 
115
161
  private
116
162
 
117
- def sampled_by_upstream(span)
118
- span.sampled = priority_keep?(span.context.sampling_priority)
163
+ def pre_sample?(span)
164
+ case @pre_sampler
165
+ when RateSampler
166
+ @pre_sampler.sample_rate < 1.0
167
+ when RateByServiceSampler
168
+ @pre_sampler.sample_rate(span) < 1.0
169
+ else
170
+ true
171
+ end
172
+ end
173
+
174
+ def priority_assigned_upstream?(span)
175
+ span.context && !span.context.sampling_priority.nil?
119
176
  end
120
177
 
121
- def priority_keep?(sampling_priority)
122
- sampling_priority == Datadog::Ext::Priority::USER_KEEP || sampling_priority == Datadog::Ext::Priority::AUTO_KEEP
178
+ def priority_sample(span)
179
+ @priority_sampler.sample?(span)
123
180
  end
124
181
 
125
- def perform_sampling(span)
126
- @base_sampler.sample(span) && @post_sampler.sample(span)
182
+ def assign_priority!(span, priority)
183
+ if span.context
184
+ span.context.sampling_priority = priority
185
+ else
186
+ # Set the priority directly on the span instead, since otherwise
187
+ # it won't receive the appropriate tag.
188
+ span.set_metric(
189
+ Ext::DistributedTracing::SAMPLING_PRIORITY_KEY,
190
+ priority
191
+ )
192
+ end
127
193
  end
128
194
  end
129
195
  end
@@ -229,7 +229,7 @@ module Datadog
229
229
  span = Span.new(self, name, opts)
230
230
  if parent.nil?
231
231
  # root span
232
- @sampler.sample(span)
232
+ @sampler.sample!(span)
233
233
  span.set_tag('system.pid', Process.pid)
234
234
  if ctx && ctx.trace_id && ctx.span_id
235
235
  span.trace_id = ctx.trace_id
@@ -2,7 +2,7 @@ module Datadog
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 19
5
- PATCH = 0
5
+ PATCH = 1
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
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.19.0
4
+ version: 0.19.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: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2019-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -182,16 +182,16 @@ dependencies:
182
182
  name: sqlite3
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '0'
187
+ version: 1.3.6
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '0'
194
+ version: 1.3.6
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: addressable
197
197
  requirement: !ruby/object:Gem::Requirement