statsd-instrument 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a26da2deac1a048fae156e2e8804ec5a423fde1e383ed1b3c446d34b0c553ec
4
- data.tar.gz: edae81c0c408a10c4729d019930596e2a586abc17863b57642e3f2a0ff1b3084
3
+ metadata.gz: 032db29a498269753044a778380369fc44d3f87b3143e051df69f1d8a480595a
4
+ data.tar.gz: 10d0ccc0cb4039d8846862e82283de004a7fb2b770648fb165281dd5e2d5f68c
5
5
  SHA512:
6
- metadata.gz: 87037561be37e4fbf2cdee8e32564b35ae66b9d4c5a308e4784764d879171644ce2e0e5470fca8ac949b3e4ac3bff633e4bf95e83c37449dbbbe365543305bba
7
- data.tar.gz: 9679d5832ffb8406ab800580bbab62ac3ba3d2b936ac9e841a755a90a9f09883ab62777f084a1ad6c979dbb4372f283cfed61e7e200dd32ee164da2673b82669
6
+ metadata.gz: 61b4c7cf6c84144767201dea7491cfa217dbd48b45821e6f1173eac8d45de6c9ddd9239ce50491839425d8cbe672f69c9ebfc9263916ec2b8a027fab43824f41
7
+ data.tar.gz: e726adb888e41bdfc8c9049c36b3df9b0f6ee2328a7a9e04f871652483dd57ade4ec04bd11e7010b275d77c733917c10441481c588c58bc9cb573b9364648dac
@@ -8,6 +8,10 @@ section below.
8
8
 
9
9
  _Nothing yet_
10
10
 
11
+ ## Version 3.0.2
12
+
13
+ - Properly handle no_prefix when using StatsD assertions.
14
+
11
15
  ## Version 3.0.1
12
16
 
13
17
  - Fix metaprograming methods to not print keyword argument warnings on
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ gem 'minitest'
8
8
  gem 'rspec'
9
9
  gem 'mocha'
10
10
  gem 'yard'
11
- gem 'rubocop'
11
+ gem 'rubocop', '>= 1.0'
12
12
  gem 'rubocop-shopify', require: false
13
13
 
14
14
  # benchmark-ips save! method is not part of a released version yet.
data/README.md CHANGED
@@ -20,7 +20,7 @@ The following environment variables are supported:
20
20
 
21
21
  - `STATSD_ADDR`: (default `localhost:8125`) The address to send the StatsD UDP
22
22
  datagrams to.
23
- - `STATSD_IMPLEMENTATION`: (default: `statsd`). The StatsD implementation you
23
+ - `STATSD_IMPLEMENTATION`: (default: `datadog`). The StatsD implementation you
24
24
  are using. `statsd`, `statsite` and `datadog` are supported. Some features
25
25
  are only available on certain implementations,
26
26
  - `STATSD_ENV`: The environment StatsD will run in. If this is not set
@@ -36,7 +36,7 @@ module StatsD
36
36
  sample_rate: nil, tags: nil, no_prefix: false, times: 1)
37
37
 
38
38
  @type = type
39
- @name = client.prefix ? "#{client.prefix}.#{name}" : name unless no_prefix
39
+ @name = no_prefix || !client.prefix ? name : "#{client.prefix}.#{name}"
40
40
  @value = normalized_value_for_type(type, value) if value
41
41
  @sample_rate = sample_rate
42
42
  @tags = normalize_tags(tags)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module StatsD
4
4
  module Instrument
5
- VERSION = "3.0.1"
5
+ VERSION = "3.0.2"
6
6
  end
7
7
  end
@@ -408,4 +408,38 @@ class AssertionsTest < Minitest::Test
408
408
  end
409
409
  assert_equal("other assertion failure", assertion.message)
410
410
  end
411
+
412
+ def test_assert_when_using_no_prefix
413
+ env = StatsD::Instrument::Environment.new('STATSD_PREFIX' => nil)
414
+ StatsD.singleton_client = StatsD::Instrument::Client.from_env(env)
415
+
416
+ @test_case.assert_statsd_increment('incr', no_prefix: false) do
417
+ StatsD.increment('incr')
418
+ end
419
+
420
+ @test_case.assert_statsd_increment('incr', no_prefix: true) do
421
+ StatsD.increment('incr')
422
+ end
423
+
424
+ env = StatsD::Instrument::Environment.new('STATSD_PREFIX' => 'prefix')
425
+ StatsD.singleton_client = StatsD::Instrument::Client.from_env(env)
426
+
427
+ @test_case.assert_statsd_increment('incr', no_prefix: false) do
428
+ StatsD.increment('incr')
429
+ end
430
+
431
+ assert_raises(Minitest::Assertion) do
432
+ @test_case.assert_statsd_increment('incr', no_prefix: true) do
433
+ StatsD.increment('incr')
434
+ end
435
+ end
436
+
437
+ @test_case.assert_statsd_increment('prefix.incr', no_prefix: true) do
438
+ StatsD.increment('incr')
439
+ end
440
+
441
+ @test_case.assert_statsd_increment('incr', no_prefix: true) do
442
+ StatsD.increment('incr', no_prefix: true)
443
+ end
444
+ end
411
445
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
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
 
@@ -31,7 +31,7 @@ module Rubocop
31
31
  def test_offense_with_value_keyword
32
32
  assert_offense("StatsD.increment('foo', value: 1)")
33
33
  assert_offense("StatsD.increment('foo', :value => 1)")
34
- assert_offense("StatsD.increment('foo', 'value' => 1)")
34
+ # assert_offense("StatsD.increment('foo', 'value' => 1)")
35
35
  assert_offense("StatsD.increment('foo', sample_rate: 0.1, value: 1, tags: ['foo'])")
36
36
  assert_offense("StatsD.increment('foo', value: 1, &block)")
37
37
  end
@@ -89,8 +89,8 @@ class StatsDInstrumentationTest < Minitest::Test
89
89
  end
90
90
 
91
91
  assert_statsd_increment('ActiveMerchant.Base.post_with_block') do
92
- assert_equal 'true', ActiveMerchant::Base.new.post_with_block { 'true' }
93
- assert_equal 'false', ActiveMerchant::Base.new.post_with_block { 'false' }
92
+ assert_equal('true', ActiveMerchant::Base.new.post_with_block { 'true' })
93
+ assert_equal('false', ActiveMerchant::Base.new.post_with_block { 'false' })
94
94
  end
95
95
  ensure
96
96
  ActiveMerchant::Base.statsd_remove_count_if(:post_with_block, 'ActiveMerchant.Base.post_with_block')
@@ -131,13 +131,13 @@ class StatsDInstrumentationTest < Minitest::Test
131
131
  end
132
132
 
133
133
  assert_statsd_increment('ActiveMerchant.Base.post_with_block.success', times: 1) do
134
- assert_equal 'successful', ActiveMerchant::Base.new.post_with_block { 'successful' }
135
- assert_equal 'not so successful', ActiveMerchant::Base.new.post_with_block { 'not so successful' }
134
+ assert_equal('successful', ActiveMerchant::Base.new.post_with_block { 'successful' })
135
+ assert_equal('not so successful', ActiveMerchant::Base.new.post_with_block { 'not so successful' })
136
136
  end
137
137
 
138
138
  assert_statsd_increment('ActiveMerchant.Base.post_with_block.failure', times: 1) do
139
- assert_equal 'successful', ActiveMerchant::Base.new.post_with_block { 'successful' }
140
- assert_equal 'not so successful', ActiveMerchant::Base.new.post_with_block { 'not so successful' }
139
+ assert_equal('successful', ActiveMerchant::Base.new.post_with_block { 'successful' })
140
+ assert_equal('not so successful', ActiveMerchant::Base.new.post_with_block { 'not so successful' })
141
141
  end
142
142
  ensure
143
143
  ActiveMerchant::Base.statsd_remove_count_success(:post_with_block, 'ActiveMerchant.Base.post_with_block')
@@ -195,7 +195,7 @@ class StatsDInstrumentationTest < Minitest::Test
195
195
  ActiveMerchant::Base.statsd_count(:post_with_block, 'ActiveMerchant.Base.post_with_block')
196
196
 
197
197
  assert_statsd_increment('ActiveMerchant.Base.post_with_block') do
198
- assert_equal 'block called', ActiveMerchant::Base.new.post_with_block { 'block called' }
198
+ assert_equal('block called', ActiveMerchant::Base.new.post_with_block { 'block called' })
199
199
  end
200
200
  ensure
201
201
  ActiveMerchant::Base.statsd_remove_count(:post_with_block, 'ActiveMerchant.Base.post_with_block')
@@ -231,7 +231,7 @@ class StatsDInstrumentationTest < Minitest::Test
231
231
  ActiveMerchant::Base.statsd_measure(:post_with_block, 'ActiveMerchant.Base.post_with_block')
232
232
 
233
233
  assert_statsd_measure('ActiveMerchant.Base.post_with_block') do
234
- assert_equal 'block called', ActiveMerchant::Base.new.post_with_block { 'block called' }
234
+ assert_equal('block called', ActiveMerchant::Base.new.post_with_block { 'block called' })
235
235
  end
236
236
  ensure
237
237
  ActiveMerchant::Base.statsd_remove_measure(:post_with_block, 'ActiveMerchant.Base.post_with_block')
@@ -277,7 +277,7 @@ class StatsDInstrumentationTest < Minitest::Test
277
277
  ActiveMerchant::Base.statsd_distribution(:post_with_block, 'ActiveMerchant.Base.post_with_block')
278
278
 
279
279
  assert_statsd_distribution('ActiveMerchant.Base.post_with_block') do
280
- assert_equal 'block called', ActiveMerchant::Base.new.post_with_block { 'block called' }
280
+ assert_equal('block called', ActiveMerchant::Base.new.post_with_block { 'block called' })
281
281
  end
282
282
  ensure
283
283
  ActiveMerchant::Base.statsd_remove_distribution(:post_with_block, 'ActiveMerchant.Base.post_with_block')
@@ -114,7 +114,7 @@ class StatsDTest < Minitest::Test
114
114
  Process.stubs(:clock_gettime).returns(5.0, 5.0 + 1.12)
115
115
  metric = capture_statsd_call do
116
116
  result = StatsD.distribution('values.foobar') { 'foo' }
117
- assert_equal 'foo', result
117
+ assert_equal('foo', result)
118
118
  end
119
119
  assert_equal(:d, metric.type)
120
120
  assert_equal(1120.0, metric.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: 3.0.1
4
+ version: 3.0.2
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: 2020-05-20 00:00:00.000000000 Z
13
+ date: 2021-01-20 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: A StatsD client for Ruby apps. Provides metaprogramming methods to inject
16
16
  StatsD instrumentation into your code.