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 +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/ddtrace/sampler.rb +74 -20
- data/lib/ddtrace/tracer.rb +7 -1
- data/lib/ddtrace/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e58205299222f3c3a75a0a032ad3cca7c739fc68
|
4
|
+
data.tar.gz: 41e87bd0031a447ce9267c24bd1df4c7bc2598fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b81c99d62190ba829ebca7671493dbb6a187eaf5ef8ddeaf6a6dcf1fc32f543d2acde719208e6aba0bd65f1a2690dc16b043f5649da0e16cccf7974907a7d7e
|
7
|
+
data.tar.gz: 28c7fa70a10769ed61a23bb60d1a474b939d1e3308225174110cf39fdc856ffa7745c17e9f0b1ef66f95852171ac7293138b9c6261bb75892ed5d9649552902d
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/ddtrace/sampler.rb
CHANGED
@@ -64,56 +64,110 @@ module Datadog
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
#
|
68
|
-
class
|
69
|
-
|
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
|
-
|
72
|
-
@
|
75
|
+
@default_key = default_key
|
76
|
+
@resolver = block
|
73
77
|
@mutex = Mutex.new
|
74
|
-
@
|
75
|
-
|
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 =
|
92
|
+
key = resolve(span)
|
80
93
|
|
81
94
|
@mutex.synchronize do
|
82
|
-
@
|
95
|
+
@samplers.fetch(key, default_sampler).sample?(span)
|
83
96
|
end
|
84
97
|
end
|
85
98
|
|
86
99
|
def sample!(span)
|
87
|
-
key =
|
100
|
+
key = resolve(span)
|
88
101
|
|
89
102
|
@mutex.synchronize do
|
90
|
-
@
|
103
|
+
@samplers.fetch(key, default_sampler).sample!(span)
|
91
104
|
end
|
92
105
|
end
|
93
106
|
|
94
107
|
def sample_rate(span)
|
95
|
-
key =
|
108
|
+
key = resolve(span)
|
96
109
|
|
97
110
|
@mutex.synchronize do
|
98
|
-
@
|
111
|
+
@samplers.fetch(key, default_sampler).sample_rate
|
99
112
|
end
|
100
113
|
end
|
101
114
|
|
102
|
-
def update(
|
115
|
+
def update(key, rate)
|
103
116
|
@mutex.synchronize do
|
104
|
-
|
117
|
+
set_rate(key, rate)
|
118
|
+
end
|
119
|
+
end
|
105
120
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
-
|
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
|
|
data/lib/ddtrace/tracer.rb
CHANGED
@@ -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(
|
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
|
|
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.26.
|
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-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|