statsd-instrument 2.3.0.beta → 2.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/statsd/instrument.rb +8 -3
- data/lib/statsd/instrument/version.rb +1 -1
- data/test/statsd_test.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae635ca926c0f41f78f0662748672144020ff7f
|
4
|
+
data.tar.gz: 9e9c9023f4d1d874923ee9dd25f968c8110a0d90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eca4c77bf05934fcac13b5e43e15d9d8faa1780a1767d4338273c90b60dfb598938647a9c530a01c1bb0cd954acf8460c1d765248843f55000ceed69b545cfae
|
7
|
+
data.tar.gz: 947142a1db455251acc2cbc9a265f979b46a782d53267d361c3d7cee648b7d53ac9130ca84afa91c24f7a182a72aeb3797fee380eb41d2a8ac8d7e4a264fb769
|
data/README.md
CHANGED
@@ -106,6 +106,16 @@ StatsD.set('GoogleBase.customers', "12345", sample_rate: 1.0)
|
|
106
106
|
|
107
107
|
Because you are counting unique values, the results of using a sampling value less than 1.0 can lead to unexpected, hard to interpret results.
|
108
108
|
|
109
|
+
#### StatsD.distribution
|
110
|
+
|
111
|
+
A modified gauge that submits a distribution of values over a sample period. Arithmetic and statistical calculations (percetiles, average, etc.) on the data set are peformed server side rather than client side like a histogram.
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
StatsD.distribution('shipit.redis_connection', 3)
|
115
|
+
```
|
116
|
+
|
117
|
+
*Note: This is only supported by the beta datadog implementatation.*
|
118
|
+
|
109
119
|
#### StatsD.event
|
110
120
|
|
111
121
|
An event is a (title, text) tuple that can be used to correlate metrics with something that occured within the system.
|
data/lib/statsd/instrument.rb
CHANGED
@@ -263,6 +263,8 @@ module StatsD
|
|
263
263
|
# @param key [String] The name of the metric.
|
264
264
|
# @param value [Float] The measured duration in milliseconds
|
265
265
|
# @param metric_options [Hash] Options for the metric
|
266
|
+
# the key :as_dist will submit the value as a distribution instead of a timing
|
267
|
+
# (only supported by DataDog's implementation)
|
266
268
|
# @return [StatsD::Instrument::Metric] The metric that was sent to the backend.
|
267
269
|
#
|
268
270
|
# @overload measure(key, metric_options = {}, &block)
|
@@ -270,7 +272,9 @@ module StatsD
|
|
270
272
|
# block passed to this method.
|
271
273
|
# @param key [String] The name of the metric.
|
272
274
|
# @param metric_options [Hash] Options for the metric
|
273
|
-
#
|
275
|
+
# the key :as_dist sets the metric type to a 'distribution' instead of a 'timing'
|
276
|
+
# (only supported by DataDog's implementation)
|
277
|
+
# @yield The method will yield the block that was passed to this method to measure its duration.
|
274
278
|
# @return The value that was returns by the block passed to this method.
|
275
279
|
#
|
276
280
|
# @example
|
@@ -282,10 +286,11 @@ module StatsD
|
|
282
286
|
metric_options = [value]
|
283
287
|
value = value.fetch(:value, nil)
|
284
288
|
end
|
289
|
+
type = (!metric_options.empty? && metric_options.first[:as_dist] ? :d : :ms)
|
285
290
|
|
286
291
|
result = nil
|
287
292
|
value = 1000 * StatsD::Instrument.duration { result = block.call } if block_given?
|
288
|
-
metric = collect_metric(hash_argument(metric_options).merge(type:
|
293
|
+
metric = collect_metric(hash_argument(metric_options).merge(type: type, name: key, value: value))
|
289
294
|
result = metric unless block_given?
|
290
295
|
result
|
291
296
|
end
|
@@ -339,7 +344,7 @@ module StatsD
|
|
339
344
|
collect_metric(hash_argument(metric_options).merge(type: :h, name: key, value: value))
|
340
345
|
end
|
341
346
|
|
342
|
-
|
347
|
+
# Emits a distribution metric.
|
343
348
|
# @param key [String] The name of the metric.
|
344
349
|
# @param value [Numeric] The value to record.
|
345
350
|
# @param metric_options [Hash] (default: {}) Metric options
|
data/test/statsd_test.rb
CHANGED
@@ -17,6 +17,11 @@ class StatsDTest < Minitest::Test
|
|
17
17
|
assert_equal :ms, metric.type
|
18
18
|
end
|
19
19
|
|
20
|
+
def test_statsd_measure_with_explicit_value_and_distribution_override
|
21
|
+
metric = capture_statsd_call { result = StatsD.measure('values.foobar', 42, as_dist: true) }
|
22
|
+
assert_equal :d, metric.type
|
23
|
+
end
|
24
|
+
|
20
25
|
def test_statsd_measure_with_explicit_value_as_keyword_argument
|
21
26
|
result = nil
|
22
27
|
metric = capture_statsd_call { result = StatsD.measure('values.foobar', value: 42) }
|
@@ -26,6 +31,11 @@ class StatsDTest < Minitest::Test
|
|
26
31
|
assert_equal :ms, metric.type
|
27
32
|
end
|
28
33
|
|
34
|
+
def test_statsd_measure_with_explicit_value_keyword_and_distribution_override
|
35
|
+
metric = capture_statsd_call { result = StatsD.measure('values.foobar', value: 42, as_dist: true) }
|
36
|
+
assert_equal :d, metric.type
|
37
|
+
end
|
38
|
+
|
29
39
|
def test_statsd_measure_without_value_or_block
|
30
40
|
assert_raises(ArgumentError) { StatsD.measure('values.foobar', tags: 123) }
|
31
41
|
end
|
@@ -43,6 +53,13 @@ class StatsDTest < Minitest::Test
|
|
43
53
|
assert_equal 1120.0, metric.value
|
44
54
|
end
|
45
55
|
|
56
|
+
def test_statsd_measure_use_distribution_override_for_a_block
|
57
|
+
metric = capture_statsd_call do
|
58
|
+
StatsD.measure('values.foobar', as_dist: true) { 'foo' }
|
59
|
+
end
|
60
|
+
assert_equal :d, metric.type
|
61
|
+
end
|
62
|
+
|
46
63
|
def test_statsd_measure_returns_return_value_of_block
|
47
64
|
return_value = StatsD.measure('values.foobar') { 'sarah' }
|
48
65
|
assert_equal 'sarah', return_value
|
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: 2.3.0.
|
4
|
+
version: 2.3.0.beta2
|
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: 2018-
|
13
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|