berater 0.12.0 → 0.12.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
  SHA256:
3
- metadata.gz: 72cc5fcf9c68fff6dd3988ff85897b38d6fdcff21c0e6f94d3ec098ca8b35fc7
4
- data.tar.gz: 49144f0dee2d7197740d39b9da365f9d959c730b7ece1ae761948ec9263ada75
3
+ metadata.gz: 5d3ef54656151bf378670caca07686db842a007e87e51d14195cc3f2b8d34d34
4
+ data.tar.gz: 22c6b65158ba926e78cd013c54913024c617eb5c2932297f7e4e424a72f66a14
5
5
  SHA512:
6
- metadata.gz: 401a193c358a80098f1250053983d8f1a362cd14649156a036deedeb461fd70202743764d375b04a2b6b4fb08c795ec61d013e1be342626a2c8aad7dab2cb259
7
- data.tar.gz: 55498f8b1a6bd70a64ed9053b80bc9c95b0d60043f073c302d48bb79b51677d7a3c235c07f35cc51dacec067d0c2cc8dcf972e37fb9e9baae126f69fa8aacb4f
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.merge(overloaded: !lock),
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 && lock.contention > 0 # not a failsafe lock
34
- @client.gauge(
35
- 'berater.lock.capacity',
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
@@ -1,3 +1,3 @@
1
1
  module Berater
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  end
data/lib/berater.rb CHANGED
@@ -52,8 +52,8 @@ module Berater
52
52
  end
53
53
 
54
54
  def expunge
55
- redis.scan_each(match: "#{self.name}*") do |key|
56
- redis.del key
55
+ redis.scan_each(match: "#{name}*") do |key|
56
+ redis.del(key)
57
57
  end
58
58
  end
59
59
 
@@ -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: error.to_s),
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
- Hash,
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 limit call' do
206
- expect(client).to receive(:timing).with(
207
- 'berater.limiter.limit',
208
- Float,
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.0
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-03 00:00:00.000000000 Z
11
+ date: 2021-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: meddleware