statsd-instrument 3.5.0 → 3.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f4884abfa414d10454edd851f0a15cf51b4333396cf4cd2da209f6f7e543366
4
- data.tar.gz: 2e3f6b906fd8ab8a651d683475dbb660ea37a5207de95722efdf5c467cda2c94
3
+ metadata.gz: f7ef9b0c6e5682818fc957cbe2cf4cd37180aa8178329577d5e3d53845784073
4
+ data.tar.gz: f965e44fc446ff14a96ab0818871b97c9fe5980fad1dc45be32726b2d3b2d368
5
5
  SHA512:
6
- metadata.gz: d771c8e13ef08ef146170b41024e09abbabaca4ebbfeb9c34781f04a2fdaf287776e7c79d93fe49d5ffb9ac18da82a1759d37621697d18cf9e5e423577110aae
7
- data.tar.gz: 573003d398eba6f81fb13385bf93c0ee4254c5074ba935471cd2dee659c1c2016f9c9bb44f9c71383a30b5b91129c12753c949118ebc103b6cb1595609e534e6
6
+ metadata.gz: e3830d435e3b3fc30412a0319dd58534bf4b871c40d5707a7471cd92a4d5327cc4c45a28287df14342e7402c609f8b98d36ba5a39cc3a07c1199f4e05389581d
7
+ data.tar.gz: 2b06036a80cfb1c5dcfdc16ee21a848fe2fe3165b3f05d4d64e1c9620c2fb84bab3eb48518117c3b11daea0b6d0ace2a692c78e58b1686272933e5f14626438d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ 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
+
13
+ ## Version 3.5.1
14
+
15
+ - Fix bug when passing a lambda function to dynamically set the tags in the strict mode.
16
+
9
17
  ## Version 3.5.0
10
18
 
11
19
  - Allow user to provide a lambda function to dynamically set metric tags
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
- unless expectations.empty?
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
@@ -97,8 +97,8 @@ module StatsD
97
97
  unless sample_rate.nil? || sample_rate.is_a?(Numeric)
98
98
  raise ArgumentError, "The sample_rate argument should be a number, got #{sample_rate}"
99
99
  end
100
- unless tags.nil? || tags.is_a?(Hash) || tags.is_a?(Array)
101
- raise ArgumentError, "The tags argument should be a hash or an array, got #{tags.inspect}"
100
+ unless tags.nil? || tags.is_a?(Hash) || tags.is_a?(Array) || tags.is_a?(Proc)
101
+ raise ArgumentError, "The tags argument should be a hash, a proc or an array, got #{tags.inspect}"
102
102
  end
103
103
  end
104
104
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module StatsD
4
4
  module Instrument
5
- VERSION = "3.5.0"
5
+ VERSION = "3.5.2"
6
6
  end
7
7
  end
@@ -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.0
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: 2022-10-04 00:00:00.000000000 Z
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.