statsd-instrument 2.2.1 → 2.3.0.beta
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/lib/statsd/instrument/assertions.rb +4 -0
- data/lib/statsd/instrument/backends/udp_backend.rb +1 -1
- data/lib/statsd/instrument/matchers.rb +1 -0
- data/lib/statsd/instrument/metric.rb +1 -0
- data/lib/statsd/instrument/metric_expectation.rb +2 -1
- data/lib/statsd/instrument/version.rb +1 -1
- data/lib/statsd/instrument.rb +15 -0
- data/test/statsd_test.rb +9 -0
- data/test/udp_backend_test.rb +13 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23dbeea8c2ad9492a763224eebc870d68d3ec115
|
4
|
+
data.tar.gz: b5dc664058c39b461fcd96600f3175aca88d7195
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e564fd57696fcf3ea78351ad54dc566b0cddd6ead6d18005168c482dc22ba636fed9357a3804bc1a676f6953c48a706f4b4a7f583d97acf74b24c919882e7362
|
7
|
+
data.tar.gz: 51928197842090a75ffa25c6d1837d307f90408e645b801cdab05ad0b05ba3775ec471b0e1b1cef05f250891389a84205259f5d4459ab0d43031ad038d91c0c8
|
data/CHANGELOG.md
CHANGED
@@ -23,6 +23,10 @@ module StatsD::Instrument::Assertions
|
|
23
23
|
assert_statsd_call(:h, metric_name, options, &block)
|
24
24
|
end
|
25
25
|
|
26
|
+
def assert_statsd_distribution(metric_name, options = {}, &block)
|
27
|
+
assert_statsd_call(:d, metric_name, options, &block)
|
28
|
+
end
|
29
|
+
|
26
30
|
def assert_statsd_set(metric_name, options = {}, &block)
|
27
31
|
assert_statsd_call(:s, metric_name, options, &block)
|
28
32
|
end
|
@@ -21,7 +21,7 @@ module StatsD::Instrument::Backends
|
|
21
21
|
message: 'm',
|
22
22
|
}
|
23
23
|
|
24
|
-
SUPPORTED_METRIC_TYPES = BASE_SUPPORTED_METRIC_TYPES.merge(h: true, _e: true, _sc: true)
|
24
|
+
SUPPORTED_METRIC_TYPES = BASE_SUPPORTED_METRIC_TYPES.merge(h: true, _e: true, _sc: true, d: true)
|
25
25
|
|
26
26
|
def generate_packet(metric)
|
27
27
|
packet = ""
|
@@ -49,6 +49,7 @@ class StatsD::Instrument::MetricExpectation
|
|
49
49
|
ms: 'measure',
|
50
50
|
g: 'gauge',
|
51
51
|
h: 'histogram',
|
52
|
+
d: 'distribution',
|
52
53
|
kv: 'key/value',
|
53
54
|
s: 'set',
|
54
55
|
}
|
@@ -64,4 +65,4 @@ class StatsD::Instrument::MetricExpectation
|
|
64
65
|
def inspect
|
65
66
|
"#<StatsD::Instrument::MetricExpectation #{self.to_s}>"
|
66
67
|
end
|
67
|
-
end
|
68
|
+
end
|
data/lib/statsd/instrument.rb
CHANGED
@@ -339,6 +339,21 @@ module StatsD
|
|
339
339
|
collect_metric(hash_argument(metric_options).merge(type: :h, name: key, value: value))
|
340
340
|
end
|
341
341
|
|
342
|
+
# Emits a distribution metric.
|
343
|
+
# @param key [String] The name of the metric.
|
344
|
+
# @param value [Numeric] The value to record.
|
345
|
+
# @param metric_options [Hash] (default: {}) Metric options
|
346
|
+
# @return (see #collect_metric)
|
347
|
+
# @note Supported by the datadog implementation only (in beta)
|
348
|
+
def distribution(key, value, *metric_options)
|
349
|
+
if value.is_a?(Hash) && metric_options.empty?
|
350
|
+
metric_options = [value]
|
351
|
+
value = value.fetch(:value, nil)
|
352
|
+
end
|
353
|
+
|
354
|
+
collect_metric(hash_argument(metric_options).merge(type: :d, name: key, value: value))
|
355
|
+
end
|
356
|
+
|
342
357
|
# Emits a key/value metric.
|
343
358
|
# @param key [String] The name of the metric.
|
344
359
|
# @param value [Numeric] The value to record.
|
data/test/statsd_test.rb
CHANGED
@@ -117,6 +117,15 @@ class StatsDTest < Minitest::Test
|
|
117
117
|
assert_equal 42, metric.value
|
118
118
|
end
|
119
119
|
|
120
|
+
def test_statsd_distribution
|
121
|
+
result = nil
|
122
|
+
metric = capture_statsd_call { result = StatsD.distribution('values.foobar', 42) }
|
123
|
+
assert_equal metric, result
|
124
|
+
assert_equal :d, metric.type
|
125
|
+
assert_equal 'values.foobar', metric.name
|
126
|
+
assert_equal 42, metric.value
|
127
|
+
end
|
128
|
+
|
120
129
|
def test_statsd_key_value
|
121
130
|
result = nil
|
122
131
|
metric = capture_statsd_call { result = StatsD.key_value('values.foobar', 42) }
|
data/test/udp_backend_test.rb
CHANGED
@@ -76,6 +76,12 @@ class UDPBackendTest < Minitest::Test
|
|
76
76
|
StatsD.histogram('fooh', 42.4)
|
77
77
|
end
|
78
78
|
|
79
|
+
def test_distribution_syntax_on_datadog
|
80
|
+
@backend.implementation = :datadog
|
81
|
+
@backend.expects(:write_packet).with('fooh:42.4|d')
|
82
|
+
StatsD.distribution('fooh', 42.4)
|
83
|
+
end
|
84
|
+
|
79
85
|
def test_event_on_datadog
|
80
86
|
@backend.implementation = :datadog
|
81
87
|
@backend.expects(:write_packet).with('_e{4,3}:fooh|baz|h:localhost:3000|@0.01|#foo')
|
@@ -127,6 +133,13 @@ class UDPBackendTest < Minitest::Test
|
|
127
133
|
StatsD.histogram('fooh', 42.4)
|
128
134
|
end
|
129
135
|
|
136
|
+
def test_distribution_warns_if_not_using_datadog
|
137
|
+
@backend.implementation = :other
|
138
|
+
@backend.expects(:write_packet).never
|
139
|
+
@logger.expects(:warn)
|
140
|
+
StatsD.distribution('fooh', 42.4)
|
141
|
+
end
|
142
|
+
|
130
143
|
def test_supports_key_value_syntax_on_statsite
|
131
144
|
@backend.implementation = :statsite
|
132
145
|
@backend.expects(:write_packet).with("fooy:42|kv\n")
|
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.
|
4
|
+
version: 2.3.0.beta
|
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-05-
|
13
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -158,9 +158,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
|
-
- - "
|
161
|
+
- - ">"
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version:
|
163
|
+
version: 1.3.1
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project:
|
166
166
|
rubygems_version: 2.6.14
|