statsd-instrument 2.3.0.beta4 → 2.3.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/statsd/instrument.rb +4 -2
- data/lib/statsd/instrument/version.rb +1 -1
- data/test/statsd_test.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3778ad062c094c39ea30a024aea34b09399966d1
|
4
|
+
data.tar.gz: b7f1fa108b6125fb48778520abc947ce149e2317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 143d81f6dfe35e31b3faf1d69007792b2498ef553148ed61e1eb357c170b2990ceba09d27e2b58c078d6cfd0d8c1d78fbc999f377d6142ff2d599f21b44b7058
|
7
|
+
data.tar.gz: 03c3d70cae11a1a9f92e6160b09c51fd23e275c485cb37bc468447b9ec4665431f83a1ca96ea5f4fc498ba80891573bc002ddb2a93e81353d92e18c264d95971
|
data/lib/statsd/instrument.rb
CHANGED
@@ -313,7 +313,8 @@ module StatsD
|
|
313
313
|
result = nil
|
314
314
|
value = 1000 * StatsD::Instrument.duration { result = block.call } if block_given?
|
315
315
|
metric = collect_metric(type, key, value, metric_options)
|
316
|
-
|
316
|
+
result = metric unless block_given?
|
317
|
+
result
|
317
318
|
end
|
318
319
|
|
319
320
|
# Emits a counter metric.
|
@@ -375,7 +376,8 @@ module StatsD
|
|
375
376
|
result = nil
|
376
377
|
value = 1000 * StatsD::Instrument.duration { result = block.call } if block_given?
|
377
378
|
metric = collect_metric(:d, key, value, metric_options)
|
378
|
-
|
379
|
+
result = metric unless block_given?
|
380
|
+
result
|
379
381
|
end
|
380
382
|
|
381
383
|
# Emits a key/value metric.
|
data/test/statsd_test.rb
CHANGED
@@ -65,6 +65,11 @@ class StatsDTest < Minitest::Test
|
|
65
65
|
assert_equal 'sarah', return_value
|
66
66
|
end
|
67
67
|
|
68
|
+
def test_statsd_measure_returns_return_value_of_block_even_if_nil
|
69
|
+
return_value = StatsD.measure('values.foobar', as_dist: true) { nil }
|
70
|
+
assert_nil return_value
|
71
|
+
end
|
72
|
+
|
68
73
|
def test_statsd_increment
|
69
74
|
result = nil
|
70
75
|
metric = capture_statsd_call { result = StatsD.increment('values.foobar', 3) }
|
@@ -168,6 +173,11 @@ class StatsDTest < Minitest::Test
|
|
168
173
|
assert_equal 'sarah', return_value
|
169
174
|
end
|
170
175
|
|
176
|
+
def test_statsd_measure_returns_return_value_of_block_even_if_nil
|
177
|
+
return_value = StatsD.distribution('values.foobar') { nil }
|
178
|
+
assert_nil return_value
|
179
|
+
end
|
180
|
+
|
171
181
|
def test_statsd_key_value
|
172
182
|
result = nil
|
173
183
|
metric = capture_statsd_call { result = StatsD.key_value('values.foobar', 42) }
|