berater 0.12.0 → 0.12.1
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/lib/berater/middleware/statsd.rb +23 -11
- data/lib/berater/version.rb +1 -1
- data/lib/berater.rb +2 -2
- data/spec/middleware/statsd_spec.rb +13 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d3ef54656151bf378670caca07686db842a007e87e51d14195cc3f2b8d34d34
|
4
|
+
data.tar.gz: 22c6b65158ba926e78cd013c54913024c617eb5c2932297f7e4e424a72f66a14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2743af38d4daf9cd5d18a06368834545add59fb6d192fdf17c7f503ab059961177c444e5b09efde6a8ed6739b4cca04d83e7e88f8d904d0bd3e2b1bc94220cfb
|
7
|
+
data.tar.gz: a6750a44bcd05a1d0b25ff770d3c1d0f6fd3fd331cfebebbecdebd4ef06bc4f5a34d350cc36414cce7b212e7e63f8bb1d10cc4d25788ae50e1b973dfd280be4e
|
@@ -21,7 +21,7 @@ module Berater
|
|
21
21
|
@client.timing(
|
22
22
|
'berater.limiter.limit',
|
23
23
|
duration,
|
24
|
-
tags: tags
|
24
|
+
tags: tags,
|
25
25
|
)
|
26
26
|
|
27
27
|
@client.gauge(
|
@@ -30,21 +30,33 @@ module Berater
|
|
30
30
|
tags: tags,
|
31
31
|
)
|
32
32
|
|
33
|
-
if lock
|
34
|
-
@client.
|
35
|
-
'berater.lock.
|
36
|
-
lock.capacity,
|
37
|
-
tags: tags,
|
38
|
-
)
|
39
|
-
@client.gauge(
|
40
|
-
'berater.limiter.contention',
|
41
|
-
lock.contention,
|
33
|
+
if lock
|
34
|
+
@client.increment(
|
35
|
+
'berater.lock.acquired',
|
42
36
|
tags: tags,
|
43
37
|
)
|
38
|
+
|
39
|
+
if lock.contention > 0 # not a failsafe lock
|
40
|
+
@client.gauge(
|
41
|
+
'berater.lock.capacity',
|
42
|
+
lock.capacity,
|
43
|
+
tags: tags,
|
44
|
+
)
|
45
|
+
@client.gauge(
|
46
|
+
'berater.limiter.contention',
|
47
|
+
lock.contention,
|
48
|
+
tags: tags,
|
49
|
+
)
|
50
|
+
end
|
44
51
|
end
|
45
52
|
|
46
53
|
if error
|
47
54
|
if error.is_a?(Berater::Overloaded)
|
55
|
+
@client.increment(
|
56
|
+
'berater.limiter.overloaded',
|
57
|
+
tags: tags,
|
58
|
+
)
|
59
|
+
|
48
60
|
# overloaded, so contention >= capacity
|
49
61
|
@client.gauge(
|
50
62
|
'berater.limiter.contention',
|
@@ -54,7 +66,7 @@ module Berater
|
|
54
66
|
else
|
55
67
|
@client.increment(
|
56
68
|
'berater.limiter.error',
|
57
|
-
tags: tags.merge(type: error.class.to_s)
|
69
|
+
tags: tags.merge(type: error.class.to_s.gsub('::', '_'))
|
58
70
|
)
|
59
71
|
end
|
60
72
|
end
|
data/lib/berater/version.rb
CHANGED
data/lib/berater.rb
CHANGED
@@ -31,7 +31,6 @@ describe Berater::Middleware::Statsd do
|
|
31
31
|
tags: {
|
32
32
|
key: limiter.key,
|
33
33
|
limiter: String,
|
34
|
-
overloaded: false,
|
35
34
|
},
|
36
35
|
)
|
37
36
|
end
|
@@ -44,6 +43,13 @@ describe Berater::Middleware::Statsd do
|
|
44
43
|
)
|
45
44
|
end
|
46
45
|
|
46
|
+
it 'tracks lock acquisition' do
|
47
|
+
expect(client).to receive(:increment).with(
|
48
|
+
'berater.lock.acquired',
|
49
|
+
Hash
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
47
53
|
context 'when custom tags are passed in' do
|
48
54
|
let(:opts) { { tags: { abc: 123 } } }
|
49
55
|
|
@@ -135,7 +141,7 @@ describe Berater::Middleware::Statsd do
|
|
135
141
|
it 'tracks limiter exceptions' do
|
136
142
|
expect(client).to receive(:increment).with(
|
137
143
|
'berater.limiter.error',
|
138
|
-
tags: hash_including(type:
|
144
|
+
tags: hash_including(type: 'Redis_TimeoutError'),
|
139
145
|
)
|
140
146
|
|
141
147
|
expect { limiter.limit }.to raise_error(error)
|
@@ -175,7 +181,7 @@ describe Berater::Middleware::Statsd do
|
|
175
181
|
it 'tracks the exception' do
|
176
182
|
expect(client).to receive(:increment).with(
|
177
183
|
'berater.limiter.error',
|
178
|
-
|
184
|
+
anything,
|
179
185
|
)
|
180
186
|
|
181
187
|
limiter.limit
|
@@ -202,11 +208,10 @@ describe Berater::Middleware::Statsd do
|
|
202
208
|
expect { limiter.limit }.to be_overloaded
|
203
209
|
end
|
204
210
|
|
205
|
-
it 'tracks the
|
206
|
-
expect(client).to receive(:
|
207
|
-
'berater.limiter.
|
208
|
-
|
209
|
-
tags: hash_including(overloaded: true),
|
211
|
+
it 'tracks the overloaded count' do
|
212
|
+
expect(client).to receive(:increment).with(
|
213
|
+
'berater.limiter.overloaded',
|
214
|
+
Hash
|
210
215
|
)
|
211
216
|
end
|
212
217
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pepper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: meddleware
|