statsd-instrument 3.5.1 → 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/lib/statsd/instrument/assertions.rb +3 -1
- data/lib/statsd/instrument/version.rb +1 -1
- data/test/assertions_test.rb +17 -0
- 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: f7ef9b0c6e5682818fc957cbe2cf4cd37180aa8178329577d5e3d53845784073
|
4
|
+
data.tar.gz: f965e44fc446ff14a96ab0818871b97c9fe5980fad1dc45be32726b2d3b2d368
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3830d435e3b3fc30412a0319dd58534bf4b871c40d5707a7471cd92a4d5327cc4c45a28287df14342e7402c609f8b98d36ba5a39cc3a07c1199f4e05389581d
|
7
|
+
data.tar.gz: 2b06036a80cfb1c5dcfdc16ee21a848fe2fe3165b3f05d4d64e1c9620c2fb84bab3eb48518117c3b11daea0b6d0ace2a692c78e58b1686272933e5f14626438d
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ section below.
|
|
6
6
|
|
7
7
|
## Unreleased changes
|
8
8
|
|
9
|
+
## Version 3.5.2
|
10
|
+
|
11
|
+
- Fix bug on assertions to allow the user passes `times: 0` as expectation.
|
12
|
+
|
9
13
|
## Version 3.5.1
|
10
14
|
|
11
15
|
- Fix bug when passing a lambda function to dynamically set the tags in the strict mode.
|
data/README.md
CHANGED
@@ -265,6 +265,8 @@ metric_tagger = lambda { |object, args| { "key": args.first } }
|
|
265
265
|
GoogleBase.statsd_count(:insert, 'GoogleBase.insert', tags: metric_tagger)
|
266
266
|
```
|
267
267
|
|
268
|
+
> You can only use the dynamic tag while using the instrumentation through metaprogramming methods
|
269
|
+
|
268
270
|
## Testing
|
269
271
|
|
270
272
|
This library comes with a module called `StatsD::Instrument::Assertions` and `StatsD::Instrument::Matchers` to help you write tests
|
@@ -165,6 +165,8 @@ module StatsD
|
|
165
165
|
filtered_datagrams = datagrams.select { |m| m.type == expectation.type && m.name == expectation.name }
|
166
166
|
|
167
167
|
if filtered_datagrams.empty?
|
168
|
+
next if expectation_times == 0
|
169
|
+
|
168
170
|
flunk("No StatsD calls for metric #{expectation.name} of type #{expectation.type} were made.")
|
169
171
|
end
|
170
172
|
|
@@ -193,7 +195,7 @@ module StatsD
|
|
193
195
|
end
|
194
196
|
expectations -= matched_expectations
|
195
197
|
|
196
|
-
|
198
|
+
if expectations.any? { |m| m.times != 0 }
|
197
199
|
flunk("Unexpected StatsD calls; the following metric expectations " \
|
198
200
|
"were not satisfied: #{expectations.inspect}")
|
199
201
|
end
|
data/test/assertions_test.rb
CHANGED
@@ -303,6 +303,23 @@ class AssertionsTest < Minitest::Test
|
|
303
303
|
StatsD.increment("counter", tags: { foo: 1 })
|
304
304
|
StatsD.increment("counter", tags: { foo: 2 })
|
305
305
|
end
|
306
|
+
|
307
|
+
foo_1_metric = StatsD::Instrument::Expectation.increment("counter", times: 2, tags: ["foo:1"])
|
308
|
+
foo_2_metric = StatsD::Instrument::Expectation.increment("counter", times: 0, tags: ["foo:2"])
|
309
|
+
@test_case.assert_statsd_expectations([foo_1_metric, foo_2_metric]) do
|
310
|
+
StatsD.increment("counter", tags: { foo: 1 })
|
311
|
+
StatsD.increment("counter", tags: { foo: 1 })
|
312
|
+
end
|
313
|
+
|
314
|
+
assert_raises(Minitest::Assertion) do
|
315
|
+
foo_1_metric = StatsD::Instrument::Expectation.increment("counter", times: 2, tags: ["foo:1"])
|
316
|
+
foo_2_metric = StatsD::Instrument::Expectation.increment("counter", times: 0, tags: ["foo:2"])
|
317
|
+
@test_case.assert_statsd_expectations([foo_1_metric, foo_2_metric]) do
|
318
|
+
StatsD.increment("counter", tags: { foo: 1 })
|
319
|
+
StatsD.increment("counter", tags: { foo: 1 })
|
320
|
+
StatsD.increment("counter", tags: { foo: 2 })
|
321
|
+
end
|
322
|
+
end
|
306
323
|
end
|
307
324
|
|
308
325
|
def test_assert_statsd_increment_with_tags
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsd-instrument
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Storimer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-01-
|
13
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: A StatsD client for Ruby apps. Provides metaprogramming methods to inject
|
16
16
|
StatsD instrumentation into your code.
|