statsd-instrument 2.6.0 → 2.7.0
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 +79 -9
- data/benchmark/datagram-client +0 -1
- data/benchmark/send-metrics-to-dev-null-log +0 -1
- data/lib/statsd/instrument.rb +66 -292
- data/lib/statsd/instrument/assertions.rb +83 -93
- data/lib/statsd/instrument/client.rb +2 -2
- data/lib/statsd/instrument/datagram.rb +12 -3
- data/lib/statsd/instrument/environment.rb +9 -3
- data/lib/statsd/instrument/expectation.rb +93 -0
- data/lib/statsd/instrument/helpers.rb +29 -11
- data/lib/statsd/instrument/legacy_client.rb +301 -0
- data/lib/statsd/instrument/metric.rb +8 -8
- data/lib/statsd/instrument/rubocop.rb +18 -0
- data/lib/statsd/instrument/rubocop/singleton_configuration.rb +53 -0
- data/lib/statsd/instrument/version.rb +1 -1
- data/test/assertions_on_legacy_client_test.rb +376 -0
- data/test/assertions_test.rb +105 -39
- data/test/capture_sink_test.rb +0 -2
- data/test/client_test.rb +0 -2
- data/test/compatibility/dogstatsd_datagram_compatibility_test.rb +0 -1
- data/test/datagram_builder_test.rb +1 -3
- data/test/datagram_test.rb +14 -0
- data/test/dogstatsd_datagram_builder_test.rb +0 -2
- data/test/environment_test.rb +1 -1
- data/test/helpers_test.rb +17 -0
- data/test/log_sink_test.rb +0 -2
- data/test/logger_backend_test.rb +2 -2
- data/test/metric_test.rb +2 -2
- data/test/null_sink_test.rb +0 -2
- data/test/rubocop/singleton_configuration_test.rb +43 -0
- data/test/statsd_datagram_builder_test.rb +0 -2
- data/test/statsd_instrumentation_test.rb +4 -6
- data/test/statsd_test.rb +1 -1
- data/test/test_helper.rb +0 -2
- data/test/udp_backend_test.rb +1 -1
- data/test/udp_sink_test.rb +0 -2
- metadata +11 -3
- data/lib/statsd/instrument/metric_expectation.rb +0 -82
data/test/statsd_test.rb
CHANGED
@@ -213,7 +213,7 @@ class StatsDTest < Minitest::Test
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def test_name_prefix
|
216
|
-
StatsD.stubs(:prefix).returns('prefix')
|
216
|
+
StatsD.legacy_singleton_client.stubs(:prefix).returns('prefix')
|
217
217
|
m = capture_statsd_call { StatsD.increment('counter') }
|
218
218
|
assert_equal 'prefix.counter', m.name
|
219
219
|
|
data/test/test_helper.rb
CHANGED
data/test/udp_backend_test.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class UDPBackendTest < Minitest::Test
|
6
6
|
def setup
|
7
|
-
StatsD.stubs(:backend).returns(@backend = StatsD::Instrument::Backends::UDPBackend.new)
|
7
|
+
StatsD.legacy_singleton_client.stubs(:backend).returns(@backend = StatsD::Instrument::Backends::UDPBackend.new)
|
8
8
|
@backend.stubs(:rand).returns(0.0)
|
9
9
|
|
10
10
|
UDPSocket.stubs(:new).returns(@socket = mock('socket'))
|
data/test/udp_sink_test.rb
CHANGED
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.7.0
|
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: 2019-10-
|
13
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -150,11 +150,12 @@ files:
|
|
150
150
|
- lib/statsd/instrument/datagram_builder.rb
|
151
151
|
- lib/statsd/instrument/dogstatsd_datagram_builder.rb
|
152
152
|
- lib/statsd/instrument/environment.rb
|
153
|
+
- lib/statsd/instrument/expectation.rb
|
153
154
|
- lib/statsd/instrument/helpers.rb
|
155
|
+
- lib/statsd/instrument/legacy_client.rb
|
154
156
|
- lib/statsd/instrument/log_sink.rb
|
155
157
|
- lib/statsd/instrument/matchers.rb
|
156
158
|
- lib/statsd/instrument/metric.rb
|
157
|
-
- lib/statsd/instrument/metric_expectation.rb
|
158
159
|
- lib/statsd/instrument/null_sink.rb
|
159
160
|
- lib/statsd/instrument/railtie.rb
|
160
161
|
- lib/statsd/instrument/rubocop.rb
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- lib/statsd/instrument/rubocop/metric_return_value.rb
|
165
166
|
- lib/statsd/instrument/rubocop/metric_value_keyword_argument.rb
|
166
167
|
- lib/statsd/instrument/rubocop/positional_arguments.rb
|
168
|
+
- lib/statsd/instrument/rubocop/singleton_configuration.rb
|
167
169
|
- lib/statsd/instrument/rubocop/splat_arguments.rb
|
168
170
|
- lib/statsd/instrument/statsd_datagram_builder.rb
|
169
171
|
- lib/statsd/instrument/strict.rb
|
@@ -171,6 +173,7 @@ files:
|
|
171
173
|
- lib/statsd/instrument/version.rb
|
172
174
|
- shipit.rubygems.yml
|
173
175
|
- statsd-instrument.gemspec
|
176
|
+
- test/assertions_on_legacy_client_test.rb
|
174
177
|
- test/assertions_test.rb
|
175
178
|
- test/benchmark/clock_gettime.rb
|
176
179
|
- test/benchmark/default_tags.rb
|
@@ -181,6 +184,7 @@ files:
|
|
181
184
|
- test/client_test.rb
|
182
185
|
- test/compatibility/dogstatsd_datagram_compatibility_test.rb
|
183
186
|
- test/datagram_builder_test.rb
|
187
|
+
- test/datagram_test.rb
|
184
188
|
- test/deprecations_test.rb
|
185
189
|
- test/dogstatsd_datagram_builder_test.rb
|
186
190
|
- test/environment_test.rb
|
@@ -198,6 +202,7 @@ files:
|
|
198
202
|
- test/rubocop/metric_return_value_test.rb
|
199
203
|
- test/rubocop/metric_value_keyword_argument_test.rb
|
200
204
|
- test/rubocop/positional_arguments_test.rb
|
205
|
+
- test/rubocop/singleton_configuration_test.rb
|
201
206
|
- test/rubocop/splat_arguments_test.rb
|
202
207
|
- test/statsd_datagram_builder_test.rb
|
203
208
|
- test/statsd_instrumentation_test.rb
|
@@ -229,6 +234,7 @@ signing_key:
|
|
229
234
|
specification_version: 4
|
230
235
|
summary: A StatsD client for Ruby apps
|
231
236
|
test_files:
|
237
|
+
- test/assertions_on_legacy_client_test.rb
|
232
238
|
- test/assertions_test.rb
|
233
239
|
- test/benchmark/clock_gettime.rb
|
234
240
|
- test/benchmark/default_tags.rb
|
@@ -239,6 +245,7 @@ test_files:
|
|
239
245
|
- test/client_test.rb
|
240
246
|
- test/compatibility/dogstatsd_datagram_compatibility_test.rb
|
241
247
|
- test/datagram_builder_test.rb
|
248
|
+
- test/datagram_test.rb
|
242
249
|
- test/deprecations_test.rb
|
243
250
|
- test/dogstatsd_datagram_builder_test.rb
|
244
251
|
- test/environment_test.rb
|
@@ -256,6 +263,7 @@ test_files:
|
|
256
263
|
- test/rubocop/metric_return_value_test.rb
|
257
264
|
- test/rubocop/metric_value_keyword_argument_test.rb
|
258
265
|
- test/rubocop/positional_arguments_test.rb
|
266
|
+
- test/rubocop/singleton_configuration_test.rb
|
259
267
|
- test/rubocop/splat_arguments_test.rb
|
260
268
|
- test/statsd_datagram_builder_test.rb
|
261
269
|
- test/statsd_instrumentation_test.rb
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# @private
|
4
|
-
class StatsD::Instrument::MetricExpectation
|
5
|
-
attr_accessor :times, :type, :name, :value, :sample_rate, :tags
|
6
|
-
attr_reader :ignore_tags
|
7
|
-
|
8
|
-
def initialize(options = {})
|
9
|
-
if options[:type]
|
10
|
-
@type = options[:type]
|
11
|
-
else
|
12
|
-
raise ArgumentError, "Metric :type is required."
|
13
|
-
end
|
14
|
-
|
15
|
-
if options[:name]
|
16
|
-
@name = options[:name]
|
17
|
-
else
|
18
|
-
raise ArgumentError, "Metric :name is required."
|
19
|
-
end
|
20
|
-
|
21
|
-
if options[:times]
|
22
|
-
@times = options[:times]
|
23
|
-
else
|
24
|
-
raise ArgumentError, "Metric :times is required."
|
25
|
-
end
|
26
|
-
|
27
|
-
@name = StatsD.prefix ? "#{StatsD.prefix}.#{@name}" : @name unless options[:no_prefix]
|
28
|
-
@tags = StatsD::Instrument::Metric.normalize_tags(options[:tags])
|
29
|
-
@sample_rate = options[:sample_rate]
|
30
|
-
@value = options[:value]
|
31
|
-
@ignore_tags = StatsD::Instrument::Metric.normalize_tags(options[:ignore_tags])
|
32
|
-
end
|
33
|
-
|
34
|
-
def matches(actual_metric)
|
35
|
-
return false if sample_rate && sample_rate != actual_metric.sample_rate
|
36
|
-
return false if value && value != actual_metric.value
|
37
|
-
|
38
|
-
if tags
|
39
|
-
|
40
|
-
expected_tags = Set.new(tags)
|
41
|
-
actual_tags = Set.new(actual_metric.tags)
|
42
|
-
|
43
|
-
if ignore_tags
|
44
|
-
ignored_tags = Set.new(ignore_tags) - expected_tags
|
45
|
-
actual_tags -= ignored_tags
|
46
|
-
|
47
|
-
if ignore_tags.is_a?(Array)
|
48
|
-
actual_tags.delete_if { |key| ignore_tags.include?(key.split(":").first) }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
return expected_tags.subset?(actual_tags)
|
53
|
-
end
|
54
|
-
true
|
55
|
-
end
|
56
|
-
|
57
|
-
def default_value
|
58
|
-
1 if type == :c
|
59
|
-
end
|
60
|
-
|
61
|
-
TYPES = {
|
62
|
-
c: 'increment',
|
63
|
-
ms: 'measure',
|
64
|
-
g: 'gauge',
|
65
|
-
h: 'histogram',
|
66
|
-
d: 'distribution',
|
67
|
-
kv: 'key/value',
|
68
|
-
s: 'set',
|
69
|
-
}
|
70
|
-
|
71
|
-
def to_s
|
72
|
-
str = +"#{TYPES[type]} #{name}:#{value}"
|
73
|
-
str << " @#{sample_rate}" if sample_rate != 1.0
|
74
|
-
str << " " << tags.map { |t| "##{t}" }.join(' ') if tags
|
75
|
-
str << " times:#{times}" if times > 1
|
76
|
-
str
|
77
|
-
end
|
78
|
-
|
79
|
-
def inspect
|
80
|
-
"#<StatsD::Instrument::MetricExpectation #{self}>"
|
81
|
-
end
|
82
|
-
end
|