statsd-instrument 2.9.2 → 3.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +0 -11
  3. data/benchmark/send-metrics-to-dev-null-log +4 -2
  4. data/benchmark/send-metrics-to-local-udp-receiver +7 -6
  5. data/lib/statsd/instrument.rb +35 -69
  6. data/lib/statsd/instrument/assertions.rb +14 -14
  7. data/lib/statsd/instrument/client.rb +0 -10
  8. data/lib/statsd/instrument/environment.rb +1 -23
  9. data/lib/statsd/instrument/expectation.rb +14 -14
  10. data/lib/statsd/instrument/helpers.rb +1 -30
  11. data/lib/statsd/instrument/railtie.rb +0 -4
  12. data/lib/statsd/instrument/strict.rb +12 -118
  13. data/lib/statsd/instrument/version.rb +1 -1
  14. data/test/assertions_test.rb +9 -21
  15. data/test/client_test.rb +11 -0
  16. data/test/environment_test.rb +1 -37
  17. data/test/integration_test.rb +9 -24
  18. data/test/statsd_instrumentation_test.rb +25 -50
  19. data/test/statsd_test.rb +2 -29
  20. metadata +4 -26
  21. data/benchmark/datagram-client +0 -40
  22. data/lib/statsd/instrument/backend.rb +0 -18
  23. data/lib/statsd/instrument/backends/capture_backend.rb +0 -32
  24. data/lib/statsd/instrument/backends/logger_backend.rb +0 -20
  25. data/lib/statsd/instrument/backends/null_backend.rb +0 -9
  26. data/lib/statsd/instrument/backends/udp_backend.rb +0 -152
  27. data/lib/statsd/instrument/legacy_client.rb +0 -301
  28. data/lib/statsd/instrument/metric.rb +0 -155
  29. data/test/assertions_on_legacy_client_test.rb +0 -344
  30. data/test/capture_backend_test.rb +0 -26
  31. data/test/compatibility/dogstatsd_datagram_compatibility_test.rb +0 -161
  32. data/test/deprecations_test.rb +0 -139
  33. data/test/logger_backend_test.rb +0 -22
  34. data/test/metric_test.rb +0 -47
  35. data/test/udp_backend_test.rb +0 -228
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50951cc1d5be4659f87b7a6b4b2b820250b768a8a888bad19f85beb30cf77acd
4
- data.tar.gz: 2dc9c84774e437ba6e64b221197b228d36ece95c42428f70eb43262028cca2b5
3
+ metadata.gz: ec03c4f1452d2b5bca53c83faf68955d8095ad75ed0484103091789764e02233
4
+ data.tar.gz: 6037bd8e41bfc3b7d726c9f1120d10ce202a206dbfdd1e3368d550ed90f0bcc9
5
5
  SHA512:
6
- metadata.gz: eabe89b8d4184ade826b5e68bb3fcf27a10330a454cefb4b9ecbb7583d4e5ab919878e7faa6e8a8e702bdcbe09c35fa4a4b6b37048f52f8970753c6225830632
7
- data.tar.gz: a0a3f0a646c9669918faf6e4f5f6a0b8a0cfeb9db6128cb0350bafbd9f78ab778add4fe01cbab6a43bccc2ad91eac93721b9bd46cfe8d877cff43e5bec762e67
6
+ metadata.gz: f282acf3e05dac8b66eddc5b2fb8e11501543bc2125c92d7154835bd832304d706e35dc831c7c4ea879f05f4f1b0568b67bd19e4a657ef45c8272c81aa29b0af
7
+ data.tar.gz: 65546513cc2e0fb9ea06ab220d63102ba354963397c96ae8d81983d3b9178ca8ca03ed1536c29a8d2938b125e7644a37cdc40c0707d9eab1ccca2298bd3b6ad1
@@ -8,17 +8,6 @@ section below.
8
8
 
9
9
  _Nothing yet_
10
10
 
11
- ## Version 2.9.2
12
-
13
- - Allow providing a value as second positional argument to `assert_statsd_*`
14
- methods, rather than as keyword argument. This matches the arguments to the
15
- StatsD metric call.
16
- ``` ruby
17
- assert_statsd_increment('batch_size', 10) do
18
- StatsD.increment('batch_size', 10)
19
- end
20
- ```
21
-
22
11
  ## Version 2.9.1
23
12
 
24
13
  - The `VOID` object being returned by metric methods (e.g. `StatsD.increment`)
@@ -25,8 +25,10 @@ report = Benchmark.ips do |bench|
25
25
  StatsD.measure('StatsD.measure') { 1 + 1 }
26
26
  StatsD.gauge('StatsD.gauge', 12.0, tags: ["foo:bar", "quc"])
27
27
  StatsD.set('StatsD.set', 'value', tags: { foo: 'bar', baz: 'quc' })
28
- StatsD.event('StasD.event', "12345")
29
- StatsD.service_check("StatsD.service_check", "ok")
28
+ if StatsD.singleton_client.datagram_builder_class == StatsD::Instrument::DogStatsDDatagramBuilder
29
+ StatsD.event('StasD.event', "12345")
30
+ StatsD.service_check("StatsD.service_check", "ok")
31
+ end
30
32
  end
31
33
 
32
34
  # Store the results in between runs
@@ -4,6 +4,7 @@
4
4
  require 'bundler/setup'
5
5
  require 'benchmark/ips'
6
6
  require 'socket'
7
+ require 'statsd-instrument'
7
8
 
8
9
  revision = %x(git rev-parse HEAD).rstrip
9
10
  master_revision = %x(git rev-parse origin/master).rstrip
@@ -20,11 +21,11 @@ FileUtils.mkdir_p(File.dirname(intermediate_results_filename))
20
21
  receiver = UDPSocket.new
21
22
  receiver.bind('localhost', 0)
22
23
 
23
- ENV['ENV'] = "production"
24
- ENV['STATSD_ADDR'] = "#{receiver.addr[2]}:#{receiver.addr[1]}"
25
- ENV['STATSD_IMPLEMENTATION'] ||= 'datadog'
26
-
27
- require 'statsd-instrument'
24
+ StatsD.singleton_client = StatsD::Instrument::Environment.new(
25
+ 'STATSD_ADDR' => "#{receiver.addr[2]}:#{receiver.addr[1]}",
26
+ 'STATSD_IMPLEMENTATION' => 'dogstatsd',
27
+ 'STATSD_ENV' => 'production',
28
+ ).client
28
29
 
29
30
  report = Benchmark.ips do |bench|
30
31
  bench.report("StatsD metrics to local UDP receiver (branch: #{branch}, sha: #{revision[0, 7]})") do
@@ -32,7 +33,7 @@ report = Benchmark.ips do |bench|
32
33
  StatsD.measure('StatsD.measure') { 1 + 1 }
33
34
  StatsD.gauge('StatsD.gauge', 12.0, tags: ["foo:bar", "quc"])
34
35
  StatsD.set('StatsD.set', 'value', tags: { foo: 'bar', baz: 'quc' })
35
- if StatsD.backend.implementation == :datadog
36
+ if StatsD.singleton_client.datagram_builder_class == StatsD::Instrument::DogStatsDDatagramBuilder
36
37
  StatsD.event('StasD.event', "12345")
37
38
  StatsD.service_check("StatsD.service_check", "ok")
38
39
  end
@@ -48,40 +48,36 @@ require 'forwardable'
48
48
  # @return [Array<String>, Hash<String, String>, nil] The default tags, or <tt>nil</tt> when no default tags is used
49
49
  # @deprecated
50
50
  #
51
- # @!attribute legacy_singleton_client
52
- # @nodoc
53
- # @deprecated
54
- #
55
51
  # @!attribute singleton_client
56
52
  # @nodoc
57
53
  # @deprecated
58
54
  #
59
55
  # @!method measure(name, value = nil, sample_rate: nil, tags: nil, &block)
60
- # (see StatsD::Instrument::LegacyClient#measure)
56
+ # (see StatsD::Instrument::Client#measure)
61
57
  #
62
58
  # @!method increment(name, value = 1, sample_rate: nil, tags: nil)
63
- # (see StatsD::Instrument::LegacyClient#increment)
59
+ # (see StatsD::Instrument::Client#increment)
64
60
  #
65
61
  # @!method gauge(name, value, sample_rate: nil, tags: nil)
66
- # (see StatsD::Instrument::LegacyClient#gauge)
62
+ # (see StatsD::Instrument::Client#gauge)
67
63
  #
68
64
  # @!method set(name, value, sample_rate: nil, tags: nil)
69
- # (see StatsD::Instrument::LegacyClient#set)
65
+ # (see StatsD::Instrument::Client#set)
70
66
  #
71
67
  # @!method histogram(name, value, sample_rate: nil, tags: nil)
72
- # (see StatsD::Instrument::LegacyClient#histogram)
68
+ # (see StatsD::Instrument::Client#histogram)
73
69
  #
74
70
  # @!method distribution(name, value = nil, sample_rate: nil, tags: nil, &block)
75
- # (see StatsD::Instrument::LegacyClient#distribution)
71
+ # (see StatsD::Instrument::Client#distribution)
76
72
  #
77
73
  # @!method key_value(name, value)
78
- # (see StatsD::Instrument::LegacyClient#key_value)
74
+ # (see StatsD::Instrument::Client#key_value)
79
75
  #
80
76
  # @!method event(title, text, tags: nil, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) # rubocop:disable Metrics/LineLength
81
- # (see StatsD::Instrument::LegacyClient#event)
77
+ # (see StatsD::Instrument::Client#event)
82
78
  #
83
79
  # @!method service_check(name, status, tags: nil, hostname: nil, timestamp: nil, message: nil)
84
- # (see StatsD::Instrument::LegacyClient#service_check)
80
+ # (see StatsD::Instrument::Client#service_check)
85
81
  #
86
82
  # @see StatsD::Instrument <tt>StatsD::Instrument</tt> contains module to instrument
87
83
  # existing methods with StatsD metrics
@@ -104,10 +100,8 @@ module StatsD
104
100
  end
105
101
 
106
102
  # @private
107
- def self.generate_metric_name(prefix, key, callee, *args)
108
- name = key.respond_to?(:call) ? key.call(callee, args).gsub('::', '.') : key.gsub('::', '.')
109
- name = "#{prefix}.#{name}" if prefix
110
- name
103
+ def self.generate_metric_name(name, callee, *args)
104
+ name.respond_to?(:call) ? name.call(callee, args).gsub('::', '.') : name.gsub('::', '.')
111
105
  end
112
106
 
113
107
  # Even though this method is considered private, and is no longer used internally,
@@ -139,21 +133,12 @@ module StatsD
139
133
  # callable to dynamically generate a metric name
140
134
  # @param metric_options (see StatsD#measure)
141
135
  # @return [void]
142
- def statsd_measure(method, name, deprecated_sample_rate_arg = nil, deprecated_tags_arg = nil,
143
- as_dist: false, sample_rate: deprecated_sample_rate_arg, tags: deprecated_tags_arg,
144
- prefix: nil, no_prefix: false, client: nil)
145
-
146
- if as_dist
147
- return statsd_distribution(method, name, # rubocop:disable StatsD/MetricPrefixArgument
148
- sample_rate: sample_rate, tags: tags, prefix: prefix, no_prefix: no_prefix)
149
- end
150
-
136
+ def statsd_measure(method, name, sample_rate: nil, tags: nil, no_prefix: false, client: nil)
151
137
  add_to_method(method, name, :measure) do
152
138
  define_method(method) do |*args, &block|
153
139
  client ||= StatsD.singleton_client
154
- prefix ||= client.prefix unless no_prefix
155
- key = StatsD::Instrument.generate_metric_name(prefix, name, self, *args)
156
- client.measure(key, sample_rate: sample_rate, tags: tags, no_prefix: true) do
140
+ key = StatsD::Instrument.generate_metric_name(name, self, *args)
141
+ client.measure(key, sample_rate: sample_rate, tags: tags, no_prefix: no_prefix) do
157
142
  super(*args, &block)
158
143
  end
159
144
  end
@@ -168,16 +153,12 @@ module StatsD
168
153
  # @param metric_options (see StatsD#measure)
169
154
  # @return [void]
170
155
  # @note Supported by the datadog implementation only (in beta)
171
- def statsd_distribution(method, name, deprecated_sample_rate_arg = nil, deprecated_tags_arg = nil,
172
- sample_rate: deprecated_sample_rate_arg, tags: deprecated_tags_arg,
173
- prefix: nil, no_prefix: false, client: nil)
174
-
156
+ def statsd_distribution(method, name, sample_rate: nil, tags: nil, no_prefix: false, client: nil)
175
157
  add_to_method(method, name, :distribution) do
176
158
  define_method(method) do |*args, &block|
177
159
  client ||= StatsD.singleton_client
178
- prefix ||= client.prefix unless no_prefix
179
- key = StatsD::Instrument.generate_metric_name(prefix, name, self, *args)
180
- client.distribution(key, sample_rate: sample_rate, tags: tags, no_prefix: true) do
160
+ key = StatsD::Instrument.generate_metric_name(name, self, *args)
161
+ client.distribution(key, sample_rate: sample_rate, tags: tags, no_prefix: no_prefix) do
181
162
  super(*args, &block)
182
163
  end
183
164
  end
@@ -199,10 +180,7 @@ module StatsD
199
180
  # @yieldreturn [Boolean] Return true iff the return value is considered a success, false otherwise.
200
181
  # @return [void]
201
182
  # @see #statsd_count_if
202
- def statsd_count_success(method, name, deprecated_sample_rate_arg = nil, deprecated_tags_arg = nil,
203
- sample_rate: deprecated_sample_rate_arg, tags: deprecated_tags_arg,
204
- prefix: nil, no_prefix: false, client: nil)
205
-
183
+ def statsd_count_success(method, name, sample_rate: nil, tags: nil, no_prefix: false, client: nil)
206
184
  add_to_method(method, name, :count_success) do
207
185
  define_method(method) do |*args, &block|
208
186
  begin
@@ -222,10 +200,8 @@ module StatsD
222
200
  ensure
223
201
  client ||= StatsD.singleton_client
224
202
  suffix = truthiness == false ? 'failure' : 'success'
225
- prefix ||= client.prefix unless no_prefix
226
- key = StatsD::Instrument.generate_metric_name(prefix, name, self, *args)
227
- client.increment("#{key}.#{suffix}",
228
- sample_rate: sample_rate, tags: tags, no_prefix: true)
203
+ key = StatsD::Instrument.generate_metric_name(name, self, *args)
204
+ client.increment("#{key}.#{suffix}", sample_rate: sample_rate, tags: tags, no_prefix: no_prefix)
229
205
  end
230
206
  end
231
207
  end
@@ -243,10 +219,7 @@ module StatsD
243
219
  # @yieldreturn (see #statsd_count_success)
244
220
  # @return [void]
245
221
  # @see #statsd_count_success
246
- def statsd_count_if(method, name, deprecated_sample_rate_arg = nil, deprecated_tags_arg = nil,
247
- sample_rate: deprecated_sample_rate_arg, tags: deprecated_tags_arg,
248
- prefix: nil, no_prefix: false, client: nil)
249
-
222
+ def statsd_count_if(method, name, sample_rate: nil, tags: nil, no_prefix: false, client: nil)
250
223
  add_to_method(method, name, :count_if) do
251
224
  define_method(method) do |*args, &block|
252
225
  begin
@@ -266,9 +239,8 @@ module StatsD
266
239
  ensure
267
240
  if truthiness
268
241
  client ||= StatsD.singleton_client
269
- prefix ||= client.prefix unless no_prefix
270
- key = StatsD::Instrument.generate_metric_name(prefix, name, self, *args)
271
- client.increment(key, sample_rate: sample_rate, tags: tags, no_prefix: true)
242
+ key = StatsD::Instrument.generate_metric_name(name, self, *args)
243
+ client.increment(key, sample_rate: sample_rate, tags: tags, no_prefix: no_prefix)
272
244
  end
273
245
  end
274
246
  end
@@ -284,16 +256,12 @@ module StatsD
284
256
  # @param name (see #statsd_measure)
285
257
  # @param metric_options (see #statsd_measure)
286
258
  # @return [void]
287
- def statsd_count(method, name, deprecated_sample_rate_arg = nil, deprecated_tags_arg = nil,
288
- sample_rate: deprecated_sample_rate_arg, tags: deprecated_tags_arg,
289
- prefix: nil, no_prefix: false, client: nil)
290
-
259
+ def statsd_count(method, name, sample_rate: nil, tags: nil, no_prefix: false, client: nil)
291
260
  add_to_method(method, name, :count) do
292
261
  define_method(method) do |*args, &block|
293
262
  client ||= StatsD.singleton_client
294
- prefix ||= client.prefix unless no_prefix
295
- key = StatsD::Instrument.generate_metric_name(prefix, name, self, *args)
296
- client.increment(key, sample_rate: sample_rate, tags: tags, no_prefix: true)
263
+ key = StatsD::Instrument.generate_metric_name(name, self, *args)
264
+ client.increment(key, sample_rate: sample_rate, tags: tags, no_prefix: no_prefix)
297
265
  super(*args, &block)
298
266
  end
299
267
  end
@@ -400,10 +368,6 @@ module StatsD
400
368
 
401
369
  extend Forwardable
402
370
 
403
- def legacy_singleton_client
404
- StatsD::Instrument::LegacyClient.singleton
405
- end
406
-
407
371
  def singleton_client
408
372
  @singleton_client ||= StatsD::Instrument::Environment.current.client
409
373
  end
@@ -411,17 +375,19 @@ module StatsD
411
375
  # Singleton methods will be delegated to the singleton client.
412
376
  def_delegators :singleton_client, :increment, :gauge, :set, :measure,
413
377
  :histogram, :distribution, :key_value, :event, :service_check
414
-
415
- # Deprecated methods will be delegated to the legacy client
416
- def_delegators :legacy_singleton_client, :default_tags, :default_tags=,
417
- :default_sample_rate, :default_sample_rate=, :prefix, :prefix=, :backend, :backend=
418
378
  end
419
379
 
420
380
  require 'statsd/instrument/version'
421
- require 'statsd/instrument/metric'
422
- require 'statsd/instrument/legacy_client'
423
- require 'statsd/instrument/backend'
424
381
  require 'statsd/instrument/client'
382
+ require 'statsd/instrument/datagram'
383
+ require 'statsd/instrument/dogstatsd_datagram'
384
+ require 'statsd/instrument/datagram_builder'
385
+ require 'statsd/instrument/statsd_datagram_builder'
386
+ require 'statsd/instrument/dogstatsd_datagram_builder'
387
+ require 'statsd/instrument/null_sink'
388
+ require 'statsd/instrument/udp_sink'
389
+ require 'statsd/instrument/capture_sink'
390
+ require 'statsd/instrument/log_sink'
425
391
  require 'statsd/instrument/environment'
426
392
  require 'statsd/instrument/helpers'
427
393
  require 'statsd/instrument/assertions'
@@ -71,8 +71,8 @@ module StatsD::Instrument::Assertions
71
71
  # @return [void]
72
72
  # @raise [Minitest::Assertion] If an exception occurs, or if the metric did
73
73
  # not occur as specified during the execution the block.
74
- def assert_statsd_increment(metric_name, value = nil, datagrams: nil, client: nil, **options, &block)
75
- expectation = StatsD::Instrument::Expectation.increment(metric_name, value, **options)
74
+ def assert_statsd_increment(metric_name, datagrams: nil, client: nil, **options, &block)
75
+ expectation = StatsD::Instrument::Expectation.increment(metric_name, **options)
76
76
  assert_statsd_expectation(expectation, datagrams: datagrams, client: client, &block)
77
77
  end
78
78
 
@@ -83,8 +83,8 @@ module StatsD::Instrument::Assertions
83
83
  # @yield (see #assert_statsd_increment)
84
84
  # @return [void]
85
85
  # @raise (see #assert_statsd_increment)
86
- def assert_statsd_measure(metric_name, value = nil, datagrams: nil, client: nil, **options, &block)
87
- expectation = StatsD::Instrument::Expectation.measure(metric_name, value, **options)
86
+ def assert_statsd_measure(metric_name, datagrams: nil, client: nil, **options, &block)
87
+ expectation = StatsD::Instrument::Expectation.measure(metric_name, **options)
88
88
  assert_statsd_expectation(expectation, datagrams: datagrams, client: client, &block)
89
89
  end
90
90
 
@@ -95,8 +95,8 @@ module StatsD::Instrument::Assertions
95
95
  # @yield (see #assert_statsd_increment)
96
96
  # @return [void]
97
97
  # @raise (see #assert_statsd_increment)
98
- def assert_statsd_gauge(metric_name, value = nil, datagrams: nil, client: nil, **options, &block)
99
- expectation = StatsD::Instrument::Expectation.gauge(metric_name, value, **options)
98
+ def assert_statsd_gauge(metric_name, datagrams: nil, client: nil, **options, &block)
99
+ expectation = StatsD::Instrument::Expectation.gauge(metric_name, **options)
100
100
  assert_statsd_expectation(expectation, datagrams: datagrams, client: client, &block)
101
101
  end
102
102
 
@@ -107,8 +107,8 @@ module StatsD::Instrument::Assertions
107
107
  # @yield (see #assert_statsd_increment)
108
108
  # @return [void]
109
109
  # @raise (see #assert_statsd_increment)
110
- def assert_statsd_histogram(metric_name, value = nil, datagrams: nil, client: nil, **options, &block)
111
- expectation = StatsD::Instrument::Expectation.histogram(metric_name, value, **options)
110
+ def assert_statsd_histogram(metric_name, datagrams: nil, client: nil, **options, &block)
111
+ expectation = StatsD::Instrument::Expectation.histogram(metric_name, **options)
112
112
  assert_statsd_expectation(expectation, datagrams: datagrams, client: client, &block)
113
113
  end
114
114
 
@@ -119,8 +119,8 @@ module StatsD::Instrument::Assertions
119
119
  # @yield (see #assert_statsd_increment)
120
120
  # @return [void]
121
121
  # @raise (see #assert_statsd_increment)
122
- def assert_statsd_distribution(metric_name, value = nil, datagrams: nil, client: nil, **options, &block)
123
- expectation = StatsD::Instrument::Expectation.distribution(metric_name, value, **options)
122
+ def assert_statsd_distribution(metric_name, datagrams: nil, client: nil, **options, &block)
123
+ expectation = StatsD::Instrument::Expectation.distribution(metric_name, **options)
124
124
  assert_statsd_expectation(expectation, datagrams: datagrams, client: client, &block)
125
125
  end
126
126
 
@@ -131,8 +131,8 @@ module StatsD::Instrument::Assertions
131
131
  # @yield (see #assert_statsd_increment)
132
132
  # @return [void]
133
133
  # @raise (see #assert_statsd_increment)
134
- def assert_statsd_set(metric_name, value = nil, datagrams: nil, client: nil, **options, &block)
135
- expectation = StatsD::Instrument::Expectation.set(metric_name, value, **options)
134
+ def assert_statsd_set(metric_name, datagrams: nil, client: nil, **options, &block)
135
+ expectation = StatsD::Instrument::Expectation.set(metric_name, **options)
136
136
  assert_statsd_expectation(expectation, datagrams: datagrams, client: client, &block)
137
137
  end
138
138
 
@@ -143,8 +143,8 @@ module StatsD::Instrument::Assertions
143
143
  # @yield (see #assert_statsd_increment)
144
144
  # @return [void]
145
145
  # @raise (see #assert_statsd_increment)
146
- def assert_statsd_key_value(metric_name, value = nil, datagrams: nil, client: nil, **options, &block)
147
- expectation = StatsD::Instrument::Expectation.key_value(metric_name, value, **options)
146
+ def assert_statsd_key_value(metric_name, datagrams: nil, client: nil, **options, &block)
147
+ expectation = StatsD::Instrument::Expectation.key_value(metric_name, **options)
148
148
  assert_statsd_expectation(expectation, datagrams: datagrams, client: client, &block)
149
149
  end
150
150
 
@@ -1,15 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'statsd/instrument/datagram'
4
- require 'statsd/instrument/dogstatsd_datagram'
5
- require 'statsd/instrument/datagram_builder'
6
- require 'statsd/instrument/statsd_datagram_builder'
7
- require 'statsd/instrument/dogstatsd_datagram_builder'
8
- require 'statsd/instrument/null_sink'
9
- require 'statsd/instrument/udp_sink'
10
- require 'statsd/instrument/capture_sink'
11
- require 'statsd/instrument/log_sink'
12
-
13
3
  # The Client is the main interface for using StatsD.
14
4
  #
15
5
  # @note This new Client implementation is intended to become the new default in the
@@ -19,21 +19,6 @@ class StatsD::Instrument::Environment
19
19
  current.environment
20
20
  end
21
21
 
22
- # Instantiates a default backend for the current environment.
23
- #
24
- # @return [StatsD::Instrument::Backend]
25
- # @see #environment
26
- def default_backend
27
- case environment
28
- when 'production', 'staging'
29
- StatsD::Instrument::Backends::UDPBackend.new(current.statsd_addr, current.statsd_implementation)
30
- when 'test'
31
- StatsD::Instrument::Backends::NullBackend.new
32
- else
33
- StatsD::Instrument::Backends::LoggerBackend.new(StatsD.logger)
34
- end
35
- end
36
-
37
22
  # Sets default values for sample rate and logger.
38
23
  #
39
24
  # - Default sample rate is set to the value in the STATSD_SAMPLE_RATE environment variable,
@@ -45,9 +30,6 @@ class StatsD::Instrument::Environment
45
30
  #
46
31
  # @return [void]
47
32
  def setup
48
- StatsD.prefix = current.statsd_prefix
49
- StatsD.default_tags = current.statsd_default_tags
50
- StatsD.default_sample_rate = current.statsd_sample_rate
51
33
  StatsD.logger = Logger.new($stderr)
52
34
  end
53
35
  end
@@ -96,11 +78,7 @@ class StatsD::Instrument::Environment
96
78
  end
97
79
 
98
80
  def client
99
- if env.key?('STATSD_USE_NEW_CLIENT')
100
- StatsD::Instrument::Client.from_env(self)
101
- else
102
- StatsD::Instrument::LegacyClient.singleton
103
- end
81
+ StatsD::Instrument::Client.from_env(self)
104
82
  end
105
83
 
106
84
  def default_sink_for_environment
@@ -3,32 +3,32 @@
3
3
  # @private
4
4
  class StatsD::Instrument::Expectation
5
5
  class << self
6
- def increment(name, value = nil, **options)
7
- new(type: :c, name: name, value: value, **options)
6
+ def increment(name, **options)
7
+ new(type: :c, name: name, **options)
8
8
  end
9
9
 
10
- def measure(name, value = nil, **options)
11
- new(type: :ms, name: name, value: value, **options)
10
+ def measure(name, **options)
11
+ new(type: :ms, name: name, **options)
12
12
  end
13
13
 
14
- def gauge(name, value = nil, **options)
15
- new(type: :g, name: name, value: value, **options)
14
+ def gauge(name, **options)
15
+ new(type: :g, name: name, **options)
16
16
  end
17
17
 
18
- def set(name, value = nil, **options)
19
- new(type: :s, name: name, value: value, **options)
18
+ def set(name, **options)
19
+ new(type: :s, name: name, **options)
20
20
  end
21
21
 
22
- def key_value(name, value = nil, **options)
23
- new(type: :kv, name: name, value: value, **options)
22
+ def key_value(name, **options)
23
+ new(type: :kv, name: name, **options)
24
24
  end
25
25
 
26
- def distribution(name, value = nil, **options)
27
- new(type: :d, name: name, value: value, **options)
26
+ def distribution(name, **options)
27
+ new(type: :d, name: name, **options)
28
28
  end
29
29
 
30
- def histogram(name, value = nil, **options)
31
- new(type: :h, name: name, value: value, **options)
30
+ def histogram(name, **options)
31
+ new(type: :h, name: name, **options)
32
32
  end
33
33
  end
34
34