statsd-instrument 3.0.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +22 -0
  3. data/.github/workflows/{ci.yml → tests.yml} +3 -21
  4. data/.rubocop.yml +2 -1
  5. data/CHANGELOG.md +18 -0
  6. data/Gemfile +8 -10
  7. data/README.md +7 -4
  8. data/Rakefile +6 -6
  9. data/benchmark/send-metrics-to-dev-null-log +14 -14
  10. data/benchmark/send-metrics-to-local-udp-receiver +18 -18
  11. data/lib/statsd/instrument/assertions.rb +7 -7
  12. data/lib/statsd/instrument/batched_udp_sink.rb +159 -0
  13. data/lib/statsd/instrument/client.rb +3 -3
  14. data/lib/statsd/instrument/datagram.rb +1 -1
  15. data/lib/statsd/instrument/datagram_builder.rb +10 -22
  16. data/lib/statsd/instrument/dogstatsd_datagram_builder.rb +2 -2
  17. data/lib/statsd/instrument/environment.rb +19 -11
  18. data/lib/statsd/instrument/expectation.rb +6 -18
  19. data/lib/statsd/instrument/matchers.rb +8 -4
  20. data/lib/statsd/instrument/railtie.rb +1 -1
  21. data/lib/statsd/instrument/rubocop/measure_as_dist_argument.rb +1 -1
  22. data/lib/statsd/instrument/rubocop/metaprogramming_positional_arguments.rb +2 -2
  23. data/lib/statsd/instrument/rubocop/metric_prefix_argument.rb +1 -1
  24. data/lib/statsd/instrument/rubocop/metric_return_value.rb +3 -3
  25. data/lib/statsd/instrument/rubocop/metric_value_keyword_argument.rb +1 -1
  26. data/lib/statsd/instrument/rubocop/positional_arguments.rb +4 -4
  27. data/lib/statsd/instrument/rubocop/singleton_configuration.rb +1 -1
  28. data/lib/statsd/instrument/rubocop/splat_arguments.rb +2 -2
  29. data/lib/statsd/instrument/rubocop.rb +13 -34
  30. data/lib/statsd/instrument/strict.rb +1 -1
  31. data/lib/statsd/instrument/udp_sink.rb +11 -13
  32. data/lib/statsd/instrument/version.rb +1 -1
  33. data/lib/statsd/instrument.rb +56 -59
  34. data/lib/statsd-instrument.rb +1 -1
  35. data/statsd-instrument.gemspec +2 -0
  36. data/test/assertions_test.rb +200 -155
  37. data/test/benchmark/clock_gettime.rb +1 -1
  38. data/test/benchmark/metrics.rb +8 -8
  39. data/test/benchmark/tags.rb +4 -4
  40. data/test/capture_sink_test.rb +11 -11
  41. data/test/client_test.rb +64 -64
  42. data/test/datagram_builder_test.rb +41 -41
  43. data/test/datagram_test.rb +5 -5
  44. data/test/dogstatsd_datagram_builder_test.rb +22 -22
  45. data/test/environment_test.rb +26 -17
  46. data/test/helpers/rubocop_helper.rb +3 -3
  47. data/test/helpers_test.rb +12 -12
  48. data/test/integration_test.rb +6 -6
  49. data/test/log_sink_test.rb +2 -2
  50. data/test/matchers_test.rb +46 -46
  51. data/test/null_sink_test.rb +2 -2
  52. data/test/rubocop/measure_as_dist_argument_test.rb +2 -2
  53. data/test/rubocop/metaprogramming_positional_arguments_test.rb +2 -2
  54. data/test/rubocop/metric_prefix_argument_test.rb +2 -2
  55. data/test/rubocop/metric_return_value_test.rb +3 -3
  56. data/test/rubocop/metric_value_keyword_argument_test.rb +3 -3
  57. data/test/rubocop/positional_arguments_test.rb +2 -2
  58. data/test/rubocop/singleton_configuration_test.rb +8 -8
  59. data/test/rubocop/splat_arguments_test.rb +2 -2
  60. data/test/statsd_datagram_builder_test.rb +6 -6
  61. data/test/statsd_instrumentation_test.rb +104 -104
  62. data/test/statsd_test.rb +35 -35
  63. data/test/test_helper.rb +13 -6
  64. data/test/udp_sink_test.rb +142 -44
  65. metadata +21 -7
  66. data/test/benchmark/default_tags.rb +0 -47
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
3
+ require "test_helper"
4
4
 
5
5
  class DatagramTest < Minitest::Test
6
6
  def test_parsing_datagrams
7
- datagram = 'Kernel.Orders.order_creation_path:1|c|' \
8
- '#order_source:web,code_source:NilController#NilAction,order_builder:false,' \
9
- 'multi_currency:false,fulfillment_orders_beta_enabled:false'
7
+ datagram = "Kernel.Orders.order_creation_path:1|c|" \
8
+ "#order_source:web,code_source:NilController#NilAction,order_builder:false," \
9
+ "multi_currency:false,fulfillment_orders_beta_enabled:false"
10
10
 
11
11
  parsed = StatsD::Instrument::Datagram.new(datagram)
12
- assert_includes(parsed.tags, 'code_source:NilController#NilAction')
12
+ assert_includes(parsed.tags, "code_source:NilController#NilAction")
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
3
+ require "test_helper"
4
4
 
5
5
  class DogStatsDDatagramBuilderTest < Minitest::Test
6
6
  def setup
@@ -8,56 +8,56 @@ class DogStatsDDatagramBuilderTest < Minitest::Test
8
8
  end
9
9
 
10
10
  def test_raises_on_unsupported_metrics
11
- assert_raises(NotImplementedError) { @datagram_builder.kv('foo', 10, nil, nil) }
11
+ assert_raises(NotImplementedError) { @datagram_builder.kv("foo", 10, nil, nil) }
12
12
  end
13
13
 
14
14
  def test_simple_service_check
15
- datagram = @datagram_builder._sc('service', :ok)
16
- assert_equal('_sc|service|0', datagram)
15
+ datagram = @datagram_builder._sc("service", :ok)
16
+ assert_equal("_sc|service|0", datagram)
17
17
  parsed_datagram = StatsD::Instrument::DogStatsDDatagramBuilder.datagram_class.new(datagram)
18
18
  assert_equal(:_sc, parsed_datagram.type)
19
- assert_equal('service', parsed_datagram.name)
19
+ assert_equal("service", parsed_datagram.name)
20
20
  assert_equal(0, parsed_datagram.value)
21
21
  end
22
22
 
23
23
  def test_complex_service_check
24
- datagram = @datagram_builder._sc('service', :warning, timestamp: Time.parse('2019-09-30T04:22:12Z'),
25
- hostname: 'localhost', tags: { foo: 'bar|baz' }, message: 'blah')
24
+ datagram = @datagram_builder._sc("service", :warning, timestamp: Time.parse("2019-09-30T04:22:12Z"),
25
+ hostname: "localhost", tags: { foo: "bar|baz" }, message: "blah")
26
26
  assert_equal("_sc|service|1|h:localhost|d:1569817332|#foo:barbaz|m:blah", datagram)
27
27
 
28
28
  parsed_datagram = StatsD::Instrument::DogStatsDDatagramBuilder.datagram_class.new(datagram)
29
29
  assert_equal(:_sc, parsed_datagram.type)
30
- assert_equal('service', parsed_datagram.name)
30
+ assert_equal("service", parsed_datagram.name)
31
31
  assert_equal(1, parsed_datagram.value)
32
- assert_equal('localhost', parsed_datagram.hostname)
33
- assert_equal(Time.parse('2019-09-30T04:22:12Z'), parsed_datagram.timestamp)
32
+ assert_equal("localhost", parsed_datagram.hostname)
33
+ assert_equal(Time.parse("2019-09-30T04:22:12Z"), parsed_datagram.timestamp)
34
34
  assert_equal(["foo:barbaz"], parsed_datagram.tags)
35
- assert_equal('blah', parsed_datagram.message)
35
+ assert_equal("blah", parsed_datagram.message)
36
36
  end
37
37
 
38
38
  def test_simple_event
39
- datagram = @datagram_builder._e('hello', "world")
40
- assert_equal('_e{5,5}:hello|world', datagram)
39
+ datagram = @datagram_builder._e("hello", "world")
40
+ assert_equal("_e{5,5}:hello|world", datagram)
41
41
 
42
42
  parsed_datagram = StatsD::Instrument::DogStatsDDatagramBuilder.datagram_class.new(datagram)
43
43
  assert_equal(:_e, parsed_datagram.type)
44
- assert_equal('hello', parsed_datagram.name)
45
- assert_equal('world', parsed_datagram.value)
44
+ assert_equal("hello", parsed_datagram.name)
45
+ assert_equal("world", parsed_datagram.value)
46
46
  end
47
47
 
48
48
  def test_complex_event
49
- datagram = @datagram_builder._e("testing", "with\nnewline", timestamp: Time.parse('2019-09-30T04:22:12Z'),
50
- hostname: 'localhost', aggregation_key: 'my-key', priority: 'low', source_type_name: 'source',
51
- alert_type: 'success', tags: { foo: 'bar|baz' })
49
+ datagram = @datagram_builder._e("testing", "with\nnewline", timestamp: Time.parse("2019-09-30T04:22:12Z"),
50
+ hostname: "localhost", aggregation_key: "my-key", priority: "low", source_type_name: "source",
51
+ alert_type: "success", tags: { foo: "bar|baz" })
52
52
  assert_equal('_e{7,13}:testing|with\\nnewline|h:localhost|d:1569817332|k:my-key|' \
53
- 'p:low|s:source|t:success|#foo:barbaz', datagram)
53
+ "p:low|s:source|t:success|#foo:barbaz", datagram)
54
54
 
55
55
  parsed_datagram = StatsD::Instrument::DogStatsDDatagramBuilder.datagram_class.new(datagram)
56
56
  assert_equal(:_e, parsed_datagram.type)
57
- assert_equal('testing', parsed_datagram.name)
57
+ assert_equal("testing", parsed_datagram.name)
58
58
  assert_equal("with\nnewline", parsed_datagram.value)
59
- assert_equal('localhost', parsed_datagram.hostname)
60
- assert_equal(Time.parse('2019-09-30T04:22:12Z'), parsed_datagram.timestamp)
59
+ assert_equal("localhost", parsed_datagram.hostname)
60
+ assert_equal(Time.parse("2019-09-30T04:22:12Z"), parsed_datagram.timestamp)
61
61
  assert_equal(["foo:barbaz"], parsed_datagram.tags)
62
62
  assert_equal("my-key", parsed_datagram.aggregation_key)
63
63
  assert_equal("low", parsed_datagram.priority)
@@ -1,34 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
3
+ require "test_helper"
4
4
 
5
5
  module Rails; end
6
6
 
7
7
  class EnvironmentTest < Minitest::Test
8
8
  def test_environment_prefers_statsd_env_if_available
9
9
  env = StatsD::Instrument::Environment.new(
10
- 'STATSD_ENV' => 'set_from_STATSD_ENV',
11
- 'RACK_ENV' => 'set_from_RACK_ENV',
12
- 'ENV' => 'set_from_ENV',
10
+ "STATSD_ENV" => "set_from_STATSD_ENV",
11
+ "RACK_ENV" => "set_from_RACK_ENV",
12
+ "ENV" => "set_from_ENV",
13
13
  )
14
- assert_equal('set_from_STATSD_ENV', env.environment)
14
+ assert_equal("set_from_STATSD_ENV", env.environment)
15
15
  end
16
16
 
17
17
  def test_environment_uses_env_when_rails_does_not_respond_to_env_and_statsd_env_is_not_set
18
18
  env = StatsD::Instrument::Environment.new(
19
- 'ENV' => 'set_from_ENV',
19
+ "ENV" => "set_from_ENV",
20
20
  )
21
- assert_equal('set_from_ENV', env.environment)
21
+ assert_equal("set_from_ENV", env.environment)
22
22
  end
23
23
 
24
24
  def test_environment_uses_rails_env_when_rails_is_available
25
- Rails.stubs(:env).returns('production')
26
- assert_equal('production', StatsD::Instrument::Environment.environment)
25
+ Rails.stubs(:env).returns("production")
26
+ assert_equal("production", StatsD::Instrument::Environment.environment)
27
27
  end
28
28
 
29
29
  def test_environment_defaults_to_development
30
30
  env = StatsD::Instrument::Environment.new({})
31
- assert_equal('development', env.environment)
31
+ assert_equal("development", env.environment)
32
32
  end
33
33
 
34
34
  def test_client_returns_client_instance
@@ -37,22 +37,31 @@ class EnvironmentTest < Minitest::Test
37
37
  end
38
38
 
39
39
  def test_client_from_env_uses_log_sink_in_development_environment
40
- env = StatsD::Instrument::Environment.new('STATSD_USE_NEW_CLIENT' => '1', 'STATSD_ENV' => 'development')
40
+ env = StatsD::Instrument::Environment.new("STATSD_USE_NEW_CLIENT" => "1", "STATSD_ENV" => "development")
41
41
  assert_kind_of(StatsD::Instrument::LogSink, env.client.sink)
42
42
  end
43
43
 
44
44
  def test_client_from_env_uses_null_sink_in_test_environment
45
- env = StatsD::Instrument::Environment.new('STATSD_USE_NEW_CLIENT' => '1', 'STATSD_ENV' => 'test')
45
+ env = StatsD::Instrument::Environment.new("STATSD_USE_NEW_CLIENT" => "1", "STATSD_ENV" => "test")
46
46
  assert_kind_of(StatsD::Instrument::NullSink, env.client.sink)
47
47
  end
48
48
 
49
- def test_client_from_env_uses_udp_sink_in_staging_environment
50
- env = StatsD::Instrument::Environment.new('STATSD_USE_NEW_CLIENT' => '1', 'STATSD_ENV' => 'staging')
51
- assert_kind_of(StatsD::Instrument::UDPSink, env.client.sink)
49
+ def test_client_from_env_uses_batched_udp_sink_in_staging_environment
50
+ env = StatsD::Instrument::Environment.new("STATSD_USE_NEW_CLIENT" => "1", "STATSD_ENV" => "staging")
51
+ assert_kind_of(StatsD::Instrument::BatchedUDPSink, env.client.sink)
52
+ end
53
+
54
+ def test_client_from_env_uses_batched_udp_sink_in_production_environment
55
+ env = StatsD::Instrument::Environment.new("STATSD_USE_NEW_CLIENT" => "1", "STATSD_ENV" => "production")
56
+ assert_kind_of(StatsD::Instrument::BatchedUDPSink, env.client.sink)
52
57
  end
53
58
 
54
- def test_client_from_env_uses_udp_sink_in_production_environment
55
- env = StatsD::Instrument::Environment.new('STATSD_USE_NEW_CLIENT' => '1', 'STATSD_ENV' => 'production')
59
+ def test_client_from_env_uses_regular_udp_sink_when_flush_interval_is_0
60
+ env = StatsD::Instrument::Environment.new(
61
+ "STATSD_USE_NEW_CLIENT" => "1",
62
+ "STATSD_ENV" => "staging",
63
+ "STATSD_FLUSH_INTERVAL" => "0.0",
64
+ )
56
65
  assert_kind_of(StatsD::Instrument::UDPSink, env.client.sink)
57
66
  end
58
67
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rubocop'
3
+ require "rubocop"
4
+ require "rubocop/cop/legacy/corrector"
4
5
 
5
6
  module RubocopHelper
6
7
  attr_accessor :cop
@@ -33,13 +34,12 @@ module RubocopHelper
33
34
  processed_source = RuboCop::ProcessedSource.new(source, RUBY_VERSION, nil)
34
35
  investigate(processed_source)
35
36
 
36
- corrector = RuboCop::Cop::Corrector.new(processed_source.buffer, cop.corrections)
37
+ corrector = RuboCop::Cop::Legacy::Corrector.new(processed_source.buffer, cop.corrections)
37
38
  corrector.rewrite
38
39
  end
39
40
 
40
41
  def investigate(processed_source)
41
42
  forces = RuboCop::Cop::Force.all.each_with_object([]) do |klass, instances|
42
- next unless cop.join_force?(klass)
43
43
  instances << klass.new([cop])
44
44
  end
45
45
 
data/test/helpers_test.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
3
+ require "test_helper"
4
4
 
5
5
  class HelpersTest < Minitest::Test
6
6
  def setup
7
7
  test_class = Class.new(Minitest::Test)
8
8
  test_class.send(:include, StatsD::Instrument::Helpers)
9
- @test_case = test_class.new('fake')
9
+ @test_case = test_class.new("fake")
10
10
  end
11
11
 
12
12
  def test_capture_metrics_inside_block_only
13
- StatsD.increment('counter')
13
+ StatsD.increment("counter")
14
14
  metrics = @test_case.capture_statsd_calls do
15
- StatsD.increment('counter')
16
- StatsD.gauge('gauge', 12)
15
+ StatsD.increment("counter")
16
+ StatsD.gauge("gauge", 12)
17
17
  end
18
- StatsD.gauge('gauge', 15)
18
+ StatsD.gauge("gauge", 15)
19
19
 
20
20
  assert_equal(2, metrics.length)
21
- assert_equal('counter', metrics[0].name)
22
- assert_equal('gauge', metrics[1].name)
21
+ assert_equal("counter", metrics[0].name)
22
+ assert_equal("gauge", metrics[1].name)
23
23
  assert_equal(12, metrics[1].value)
24
24
  end
25
25
 
@@ -27,12 +27,12 @@ class HelpersTest < Minitest::Test
27
27
  @old_client = StatsD.singleton_client
28
28
  StatsD.singleton_client = StatsD::Instrument::Client.new
29
29
 
30
- StatsD.increment('counter')
30
+ StatsD.increment("counter")
31
31
  metrics = @test_case.capture_statsd_datagrams do
32
- StatsD.increment('counter')
33
- StatsD.gauge('gauge', 12)
32
+ StatsD.increment("counter")
33
+ StatsD.gauge("gauge", 12)
34
34
  end
35
- StatsD.gauge('gauge', 15)
35
+ StatsD.gauge("gauge", 15)
36
36
 
37
37
  assert_equal(2, metrics.length)
38
38
 
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
3
+ require "test_helper"
4
4
 
5
5
  class IntegrationTest < Minitest::Test
6
6
  def setup
7
7
  @server = UDPSocket.new
8
- @server.bind('localhost', 0)
8
+ @server.bind("localhost", 0)
9
9
 
10
10
  @env = StatsD::Instrument::Environment.new(
11
- 'STATSD_ADDR' => "#{@server.addr[2]}:#{@server.addr[1]}",
12
- 'STATSD_IMPLEMENTATION' => 'dogstatsd',
13
- 'STATSD_ENV' => 'production',
11
+ "STATSD_ADDR" => "#{@server.addr[2]}:#{@server.addr[1]}",
12
+ "STATSD_IMPLEMENTATION" => "dogstatsd",
13
+ "STATSD_ENV" => "production",
14
14
  )
15
15
 
16
16
  @old_client = StatsD.singleton_client
@@ -23,7 +23,7 @@ class IntegrationTest < Minitest::Test
23
23
  end
24
24
 
25
25
  def test_live_local_udp_socket
26
- StatsD.increment('counter')
26
+ StatsD.increment("counter")
27
27
  assert_equal("counter:1|c", @server.recvfrom(100).first)
28
28
  end
29
29
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
3
+ require "test_helper"
4
4
 
5
5
  class LogSinkTest < Minitest::Test
6
6
  def test_log_sink
@@ -10,7 +10,7 @@ class LogSinkTest < Minitest::Test
10
10
  end
11
11
 
12
12
  log_sink = StatsD::Instrument::LogSink.new(logger)
13
- log_sink << 'foo:1|c' << 'bar:1|c'
13
+ log_sink << "foo:1|c" << "bar:1|c"
14
14
 
15
15
  assert_equal(<<~LOG, log.string)
16
16
  DEBUG: [StatsD] foo:1|c
@@ -1,116 +1,116 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
4
- require 'statsd/instrument/matchers'
3
+ require "test_helper"
4
+ require "statsd/instrument/matchers"
5
5
 
6
6
  class MatchersTest < Minitest::Test
7
7
  def test_statsd_increment_matched
8
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', {})
9
- .matches?(lambda { StatsD.increment('counter') }))
8
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", {})
9
+ .matches?(lambda { StatsD.increment("counter") }))
10
10
  end
11
11
 
12
12
  def test_statsd_increment_not_matched
13
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', {})
14
- .matches?(lambda { StatsD.increment('not_counter') }))
13
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", {})
14
+ .matches?(lambda { StatsD.increment("not_counter") }))
15
15
  end
16
16
 
17
17
  def test_statsd_increment_compound_matched
18
- matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, 'counter', tags: ['a'])
19
- matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, 'counter', tags: ['b'])
18
+ matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", tags: ["a"])
19
+ matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", tags: ["b"])
20
20
 
21
21
  assert(RSpec::Matchers::BuiltIn::Compound::And.new(matcher_1, matcher_2).matches?(lambda {
22
- StatsD.increment('counter', tags: ['a'])
23
- StatsD.increment('counter', tags: ['b'])
22
+ StatsD.increment("counter", tags: ["a"])
23
+ StatsD.increment("counter", tags: ["b"])
24
24
  }))
25
25
  end
26
26
 
27
27
  def test_statsd_increment_compound_not_matched
28
- matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, 'counter', tags: ['a'])
29
- matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, 'counter', tags: ['b'])
28
+ matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", tags: ["a"])
29
+ matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", tags: ["b"])
30
30
 
31
31
  refute(RSpec::Matchers::BuiltIn::Compound::And.new(matcher_1, matcher_2).matches?(lambda {
32
- StatsD.increment('counter', tags: ['a'])
33
- StatsD.increment('counter', tags: ['a'])
32
+ StatsD.increment("counter", tags: ["a"])
33
+ StatsD.increment("counter", tags: ["a"])
34
34
  }))
35
35
  end
36
36
 
37
37
  def test_statsd_increment_with_times_matched
38
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', times: 1)
39
- .matches?(lambda { StatsD.increment('counter') }))
38
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1)
39
+ .matches?(lambda { StatsD.increment("counter") }))
40
40
  end
41
41
 
42
42
  def test_statsd_increment_with_times_not_matched
43
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', times: 2)
44
- .matches?(lambda { 3.times { StatsD.increment('counter') } }))
43
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 2)
44
+ .matches?(lambda { 3.times { StatsD.increment("counter") } }))
45
45
  end
46
46
 
47
47
  def test_statsd_increment_with_sample_rate_matched
48
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', sample_rate: 0.5)
49
- .matches?(lambda { StatsD.increment('counter', sample_rate: 0.5) }))
48
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", sample_rate: 0.5)
49
+ .matches?(lambda { StatsD.increment("counter", sample_rate: 0.5) }))
50
50
  end
51
51
 
52
52
  def test_statsd_increment_with_sample_rate_not_matched
53
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', sample_rate: 0.5)
54
- .matches?(lambda { StatsD.increment('counter', sample_rate: 0.7) }))
53
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", sample_rate: 0.5)
54
+ .matches?(lambda { StatsD.increment("counter", sample_rate: 0.7) }))
55
55
  end
56
56
 
57
57
  def test_statsd_increment_with_value_matched
58
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', value: 1)
59
- .matches?(lambda { StatsD.increment('counter') }))
58
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", value: 1)
59
+ .matches?(lambda { StatsD.increment("counter") }))
60
60
  end
61
61
 
62
62
  def test_statsd_increment_with_value_matched_when_multiple_metrics
63
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', value: 1).matches?(lambda {
64
- StatsD.increment('counter', 2)
65
- StatsD.increment('counter', 1)
63
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", value: 1).matches?(lambda {
64
+ StatsD.increment("counter", 2)
65
+ StatsD.increment("counter", 1)
66
66
  }))
67
67
  end
68
68
 
69
69
  def test_statsd_increment_with_value_not_matched_when_multiple_metrics
70
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', value: 1).matches?(lambda {
71
- StatsD.increment('counter', 2)
72
- StatsD.increment('counter', 3)
70
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", value: 1).matches?(lambda {
71
+ StatsD.increment("counter", 2)
72
+ StatsD.increment("counter", 3)
73
73
  }))
74
74
  end
75
75
 
76
76
  def test_statsd_increment_with_value_not_matched
77
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', value: 3)
78
- .matches?(lambda { StatsD.increment('counter') }))
77
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", value: 3)
78
+ .matches?(lambda { StatsD.increment("counter") }))
79
79
  end
80
80
 
81
81
  def test_statsd_increment_with_tags_matched
82
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', tags: ['a', 'b'])
83
- .matches?(lambda { StatsD.increment('counter', tags: ['a', 'b']) }))
82
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", tags: ["a", "b"])
83
+ .matches?(lambda { StatsD.increment("counter", tags: ["a", "b"]) }))
84
84
  end
85
85
 
86
86
  def test_statsd_increment_with_tags_not_matched
87
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', tags: ['a', 'b'])
88
- .matches?(lambda { StatsD.increment('counter', tags: ['c']) }))
87
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", tags: ["a", "b"])
88
+ .matches?(lambda { StatsD.increment("counter", tags: ["c"]) }))
89
89
  end
90
90
 
91
91
  def test_statsd_increment_with_times_and_value_matched
92
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', times: 2, value: 1).matches?(lambda {
93
- StatsD.increment('counter', 1)
94
- StatsD.increment('counter', 1)
92
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 2, value: 1).matches?(lambda {
93
+ StatsD.increment("counter", 1)
94
+ StatsD.increment("counter", 1)
95
95
  }))
96
96
  end
97
97
 
98
98
  def test_statsd_increment_with_times_and_value_not_matched
99
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', times: 2, value: 1).matches?(lambda {
100
- StatsD.increment('counter', 1)
101
- StatsD.increment('counter', 2)
99
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 2, value: 1).matches?(lambda {
100
+ StatsD.increment("counter", 1)
101
+ StatsD.increment("counter", 2)
102
102
  }))
103
103
  end
104
104
 
105
105
  def test_statsd_increment_with_sample_rate_and_argument_matcher_matched
106
106
  between_matcher = RSpec::Matchers::BuiltIn::BeBetween.new(0.4, 0.6).inclusive
107
- assert(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', sample_rate: between_matcher)
108
- .matches?(lambda { StatsD.increment('counter', sample_rate: 0.5) }))
107
+ assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", sample_rate: between_matcher)
108
+ .matches?(lambda { StatsD.increment("counter", sample_rate: 0.5) }))
109
109
  end
110
110
 
111
111
  def test_statsd_increment_with_sample_rate_and_argument_matcher_not_matched
112
112
  between_matcher = RSpec::Matchers::BuiltIn::BeBetween.new(0.4, 0.6).inclusive
113
- refute(StatsD::Instrument::Matchers::Increment.new(:c, 'counter', sample_rate: between_matcher)
114
- .matches?(lambda { StatsD.increment('counter', sample_rate: 0.7) }))
113
+ refute(StatsD::Instrument::Matchers::Increment.new(:c, "counter", sample_rate: between_matcher)
114
+ .matches?(lambda { StatsD.increment("counter", sample_rate: 0.7) }))
115
115
  end
116
116
  end