ddtrace 0.26.0 → 0.26.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: afb28eea48bf86f3cac41970e8b600e2f6daed82
4
- data.tar.gz: 1a712a917211717bb409754fcffda978f7146522
3
+ metadata.gz: e58205299222f3c3a75a0a032ad3cca7c739fc68
4
+ data.tar.gz: 41e87bd0031a447ce9267c24bd1df4c7bc2598fd
5
5
  SHA512:
6
- metadata.gz: be061d7e43faaafb0f1f3b45d78e556eda4bdacca67d8ac471f0588066152d84f53a4e88143dcfca4b1ea58cb4be1e74f3a75f143196a345966b8099704bf329
7
- data.tar.gz: 7b805cd9b5a623f7100f0572ab281e999e1f3e18879a0b3ddb951d30572023058d6465fd78e4d67b4011c5ec84af6a668992232217ea60ba1ac9d513cf3c40f8
6
+ metadata.gz: 7b81c99d62190ba829ebca7671493dbb6a187eaf5ef8ddeaf6a6dcf1fc32f543d2acde719208e6aba0bd65f1a2690dc16b043f5649da0e16cccf7974907a7d7e
7
+ data.tar.gz: 28c7fa70a10769ed61a23bb60d1a474b939d1e3308225174110cf39fdc856ffa7745c17e9f0b1ef66f95852171ac7293138b9c6261bb75892ed5d9649552902d
@@ -4,6 +4,16 @@
4
4
 
5
5
  ## [Unreleased (beta)]
6
6
 
7
+ ## [0.26.1] - 2019-11-26
8
+
9
+ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.26.1
10
+
11
+ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.26.0...v0.26.1
12
+
13
+ ### Fixed
14
+
15
+ - Priority sampling not activating by default (#868)
16
+
7
17
  ## [0.26.0] - 2019-08-06
8
18
 
9
19
  Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.26.0
@@ -904,6 +914,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
904
914
 
905
915
  [Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.26.0...master
906
916
  [Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.26.0...0.27-dev
917
+ [0.26.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.26.0...v0.26.1
907
918
  [0.26.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.25.1...v0.26.0
908
919
  [0.25.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.25.0...v0.25.1
909
920
  [0.25.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.24.0...v0.25.0
@@ -64,56 +64,110 @@ module Datadog
64
64
  end
65
65
  end
66
66
 
67
- # \RateByServiceSampler samples different services at different rates
68
- class RateByServiceSampler < Sampler
69
- DEFAULT_KEY = 'service:,env:'.freeze
67
+ # Samples at different rates by key.
68
+ class RateByKeySampler < Sampler
69
+ attr_reader \
70
+ :default_key
71
+
72
+ def initialize(default_key, default_rate = 1.0, &block)
73
+ raise ArgumentError, 'No resolver given!' unless block_given?
70
74
 
71
- def initialize(rate = 1.0, opts = {})
72
- @env = opts.fetch(:env, Datadog.tracer.tags[:env])
75
+ @default_key = default_key
76
+ @resolver = block
73
77
  @mutex = Mutex.new
74
- @fallback = RateSampler.new(rate)
75
- @sampler = { DEFAULT_KEY => @fallback }
78
+ @samplers = {}
79
+
80
+ set_rate(default_key, default_rate)
81
+ end
82
+
83
+ def resolve(span)
84
+ @resolver.call(span)
85
+ end
86
+
87
+ def default_sampler
88
+ @samplers[default_key]
76
89
  end
77
90
 
78
91
  def sample?(span)
79
- key = key_for(span)
92
+ key = resolve(span)
80
93
 
81
94
  @mutex.synchronize do
82
- @sampler.fetch(key, @fallback).sample?(span)
95
+ @samplers.fetch(key, default_sampler).sample?(span)
83
96
  end
84
97
  end
85
98
 
86
99
  def sample!(span)
87
- key = key_for(span)
100
+ key = resolve(span)
88
101
 
89
102
  @mutex.synchronize do
90
- @sampler.fetch(key, @fallback).sample!(span)
103
+ @samplers.fetch(key, default_sampler).sample!(span)
91
104
  end
92
105
  end
93
106
 
94
107
  def sample_rate(span)
95
- key = key_for(span)
108
+ key = resolve(span)
96
109
 
97
110
  @mutex.synchronize do
98
- @sampler.fetch(key, @fallback).sample_rate
111
+ @samplers.fetch(key, default_sampler).sample_rate
99
112
  end
100
113
  end
101
114
 
102
- def update(rate_by_service)
115
+ def update(key, rate)
103
116
  @mutex.synchronize do
104
- @sampler.delete_if { |key, _| key != DEFAULT_KEY && !rate_by_service.key?(key) }
117
+ set_rate(key, rate)
118
+ end
119
+ end
105
120
 
106
- rate_by_service.each do |key, rate|
107
- @sampler[key] ||= RateSampler.new(rate)
108
- @sampler[key].sample_rate = rate
109
- end
121
+ def update_all(rate_by_key)
122
+ @mutex.synchronize do
123
+ rate_by_key.each { |key, rate| set_rate(key, rate) }
124
+ end
125
+ end
126
+
127
+ def delete(key)
128
+ @mutex.synchronize do
129
+ @samplers.delete(key)
130
+ end
131
+ end
132
+
133
+ def delete_if(&block)
134
+ @mutex.synchronize do
135
+ @samplers.delete_if(&block)
110
136
  end
111
137
  end
112
138
 
113
139
  private
114
140
 
141
+ def set_rate(key, rate)
142
+ @samplers[key] ||= RateSampler.new(rate)
143
+ @samplers[key].sample_rate = rate
144
+ end
145
+ end
146
+
147
+ # \RateByServiceSampler samples different services at different rates
148
+ class RateByServiceSampler < RateByKeySampler
149
+ DEFAULT_KEY = 'service:,env:'.freeze
150
+
151
+ def initialize(default_rate = 1.0, options = {})
152
+ super(DEFAULT_KEY, default_rate, &method(:key_for))
153
+ @env = options[:env]
154
+ end
155
+
156
+ def update(rate_by_service)
157
+ # Remove any old services
158
+ delete_if { |key, _| key != DEFAULT_KEY && !rate_by_service.key?(key) }
159
+
160
+ # Update each service rate
161
+ update_all(rate_by_service)
162
+ end
163
+
164
+ private
165
+
115
166
  def key_for(span)
116
- "service:#{span.service},env:#{@env}"
167
+ # Resolve env dynamically, if Proc is given.
168
+ env = @env.is_a?(Proc) ? @env.call : @env
169
+
170
+ "service:#{span.service},env:#{env}"
117
171
  end
118
172
  end
119
173
 
@@ -120,6 +120,9 @@ module Datadog
120
120
 
121
121
  @mutex = Mutex.new
122
122
  @tags = {}
123
+
124
+ # Enable priority sampling by default
125
+ activate_priority_sampling!(@sampler)
123
126
  end
124
127
 
125
128
  # Updates the current \Tracer instance, so that the tracer can be configured after the
@@ -441,7 +444,10 @@ module Datadog
441
444
  @sampler = if base_sampler.is_a?(PrioritySampler)
442
445
  base_sampler
443
446
  else
444
- PrioritySampler.new(base_sampler: base_sampler)
447
+ PrioritySampler.new(
448
+ base_sampler: base_sampler,
449
+ post_sampler: Datadog::RateByServiceSampler.new(1.0, env: proc { tags[:env] })
450
+ )
445
451
  end
446
452
  end
447
453
 
@@ -2,7 +2,7 @@ module Datadog
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 26
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.26.0
4
+ version: 0.26.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-08-06 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack