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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/statsd/instrument/expectation.rb +1 -1
- data/lib/statsd/instrument/version.rb +1 -1
- data/test/assertions_test.rb +34 -0
- data/test/helpers/rubocop_helper.rb +2 -2
- data/test/rubocop/metric_value_keyword_argument_test.rb +1 -1
- data/test/statsd_instrumentation_test.rb +9 -9
- data/test/statsd_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 032db29a498269753044a778380369fc44d3f87b3143e051df69f1d8a480595a
|
4
|
+
data.tar.gz: 10d0ccc0cb4039d8846862e82283de004a7fb2b770648fb165281dd5e2d5f68c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61b4c7cf6c84144767201dea7491cfa217dbd48b45821e6f1173eac8d45de6c9ddd9239ce50491839425d8cbe672f69c9ebfc9263916ec2b8a027fab43824f41
|
7
|
+
data.tar.gz: e726adb888e41bdfc8c9049c36b3df9b0f6ee2328a7a9e04f871652483dd57ade4ec04bd11e7010b275d77c733917c10441481c588c58bc9cb573b9364648dac
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
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: `
|
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}"
|
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)
|
data/test/assertions_test.rb
CHANGED
@@ -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
|
93
|
-
assert_equal
|
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
|
135
|
-
assert_equal
|
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
|
140
|
-
assert_equal
|
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
|
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
|
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
|
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')
|
data/test/statsd_test.rb
CHANGED
@@ -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
|
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.
|
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:
|
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.
|