statsd-instrument 3.5.2 → 3.5.4
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/CHANGELOG.md +8 -0
- data/README.md +7 -0
- data/lib/statsd/instrument/matchers.rb +5 -1
- data/lib/statsd/instrument/version.rb +1 -1
- data/lib/statsd/instrument.rb +6 -0
- data/test/matchers_test.rb +20 -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: 1f32c9e4ca930e72744cd789511b99b09c07cb2ad7766df3c36490df00911985
|
4
|
+
data.tar.gz: 8732469bca8f8592285978a49e9a318fafd12fef0576ac8850de9fd8bdabbd6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 124095c32f119942d8f1e20e210ad13f95f653ab8e6ed999e473abe677957e4295a81b968da319f94ac24a884be1e2750db9965188b1962150366b850a3c49b0
|
7
|
+
data.tar.gz: 6eb6efb88b13de4c47d9f17dd9fd8b954c81c7ce0aab5a8e26cc89707539900ef98fce9f44014d14c909c8f3b2d8e80fe13e755174e52d488d47413aefbe4523
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ section below.
|
|
6
6
|
|
7
7
|
## Unreleased changes
|
8
8
|
|
9
|
+
## Version 3.5.4
|
10
|
+
|
11
|
+
- Allow user to assert different tags using RSpec composable matcher
|
12
|
+
|
13
|
+
## Version 3.5.3
|
14
|
+
|
15
|
+
- Improve shapes friendliness for Ruby 3.2+
|
16
|
+
|
9
17
|
## Version 3.5.2
|
10
18
|
|
11
19
|
- Fix bug on assertions to allow the user passes `times: 0` as expectation.
|
data/README.md
CHANGED
@@ -355,6 +355,13 @@ RSpec.describe 'Matchers' do
|
|
355
355
|
it 'will pass if there is no matching StatsD call on negative expectation' do
|
356
356
|
expect { StatsD.increment('other_counter') }.not_to trigger_statsd_increment('counter')
|
357
357
|
end
|
358
|
+
|
359
|
+
it 'will pass if every statsD call matches its call tag variations' do
|
360
|
+
expect do
|
361
|
+
StatsD.increment('counter', tags: ['variation:a'])
|
362
|
+
StatsD.increment('counter', tags: ['variation:b'])
|
363
|
+
end.to trigger_statsd_increment('counter', times: 1, tags: ["variation:a"]).and trigger_statsd_increment('counter', times: 1, tags: ["variation:b"])
|
364
|
+
end
|
358
365
|
end
|
359
366
|
end
|
360
367
|
```
|
@@ -43,7 +43,11 @@ module StatsD
|
|
43
43
|
|
44
44
|
def expect_statsd_call(metric_type, metric_name, options, &block)
|
45
45
|
metrics = capture_statsd_calls(&block)
|
46
|
-
metrics = metrics.select
|
46
|
+
metrics = metrics.select do |m|
|
47
|
+
options_tags = options[:tags] || []
|
48
|
+
metric_tags = m.tags || []
|
49
|
+
m.type == metric_type && m.name == metric_name && metric_tags.all? { |t| options_tags.include?(t) }
|
50
|
+
end
|
47
51
|
|
48
52
|
if metrics.empty?
|
49
53
|
raise RSpec::Expectations::ExpectationNotMetError, "No StatsD calls for metric #{metric_name} were made."
|
data/lib/statsd/instrument.rb
CHANGED
@@ -360,6 +360,12 @@ module StatsD
|
|
360
360
|
|
361
361
|
def_delegators :singleton_client, :increment, :gauge, :set, :measure,
|
362
362
|
:histogram, :distribution, :event, :service_check
|
363
|
+
|
364
|
+
private
|
365
|
+
|
366
|
+
def extended(klass)
|
367
|
+
klass.statsd_instrumentations # eagerly define
|
368
|
+
end
|
363
369
|
end
|
364
370
|
end
|
365
371
|
|
data/test/matchers_test.rb
CHANGED
@@ -34,6 +34,26 @@ class MatchersTest < Minitest::Test
|
|
34
34
|
}))
|
35
35
|
end
|
36
36
|
|
37
|
+
def test_statsd_increment_compound_using_and_matched
|
38
|
+
matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["a"])
|
39
|
+
matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["b"])
|
40
|
+
|
41
|
+
assert(matcher_1.and(matcher_2).matches?(lambda {
|
42
|
+
StatsD.increment("counter", tags: ["a"])
|
43
|
+
StatsD.increment("counter", tags: ["b"])
|
44
|
+
}))
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_statsd_increment_compound_using_and_not_matched
|
48
|
+
matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["a"])
|
49
|
+
matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["b"])
|
50
|
+
|
51
|
+
refute(matcher_1.and(matcher_2).matches?(lambda {
|
52
|
+
StatsD.increment("counter", tags: ["a"])
|
53
|
+
StatsD.increment("counter", tags: ["c"])
|
54
|
+
}))
|
55
|
+
end
|
56
|
+
|
37
57
|
def test_statsd_increment_with_times_matched
|
38
58
|
assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1)
|
39
59
|
.matches?(lambda { StatsD.increment("counter") }))
|
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.4
|
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-
|
13
|
+
date: 2023-02-28 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.
|