Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use :c instead of :incr to be closer to the actual protocol.

  • Loading branch information...
commit b357bfa4f11253d4c80a0e46b5453c2159efb6c7 1 parent ec6dd2e
@wvanbergen wvanbergen authored
View
4 lib/statsd/instrument.rb
@@ -158,7 +158,7 @@ def counter(key, value = 1, *metric_options)
value = 1
end
- collect(:incr, key, value, hash_argument(metric_options))
+ collect(:c, key, value, hash_argument(metric_options))
end
alias_method :increment, :counter
@@ -237,7 +237,7 @@ def clean_tags(tags)
def generate_packet(type, k, v, sample_rate = default_sample_rate, tags = nil)
command = "#{self.prefix + '.' if self.prefix}#{k}:#{v}"
case type
- when :incr
+ when :c
command << '|c'
when :ms
command << '|ms'
View
8 test/statsd_instrumentation_test.rb
@@ -63,7 +63,7 @@ def test_statsd_count_if_with_method_receiving_block
result == 'true'
end
- StatsD.expects(:collect).with(:incr, 'ActiveMerchant.Base.post_with_block', 1, {}).once
+ StatsD.expects(:collect).with(:c, 'ActiveMerchant.Base.post_with_block', 1, {}).once
assert_equal 'true', ActiveMerchant::Base.new.post_with_block { 'true' }
assert_equal 'false', ActiveMerchant::Base.new.post_with_block { 'false' }
@@ -99,8 +99,8 @@ def test_statsd_count_success_with_method_receiving_block
result == 'successful'
end
- StatsD.expects(:collect).with(:incr, 'ActiveMerchant.Base.post_with_block.success', 1, {}).once
- StatsD.expects(:collect).with(:incr, 'ActiveMerchant.Base.post_with_block.failure', 1, {}).once
+ StatsD.expects(:collect).with(:c, 'ActiveMerchant.Base.post_with_block.success', 1, {}).once
+ StatsD.expects(:collect).with(:c, 'ActiveMerchant.Base.post_with_block.failure', 1, {}).once
assert_equal 'successful', ActiveMerchant::Base.new.post_with_block { 'successful' }
assert_equal 'not so successful', ActiveMerchant::Base.new.post_with_block { 'not so successful' }
@@ -144,7 +144,7 @@ def test_statsd_count_with_name_as_lambda
def test_statsd_count_with_method_receiving_block
ActiveMerchant::Base.statsd_count :post_with_block, 'ActiveMerchant.Base.post_with_block'
- StatsD.expects(:collect).with(:incr, 'ActiveMerchant.Base.post_with_block', 1, {})
+ StatsD.expects(:collect).with(:c, 'ActiveMerchant.Base.post_with_block', 1, {})
assert_equal 'block called', ActiveMerchant::Base.new.post_with_block { 'block called' }
ActiveMerchant::Base.statsd_remove_count :post_with_block, 'ActiveMerchant.Base.post_with_block'
View
4 test/statsd_test.rb
@@ -43,12 +43,12 @@ def test_statsd_measure_with_benchmarked_value_and_options
end
def test_statsd_increment_with_hash_argument
- StatsD.expects(:collect).with(:incr, 'values.foobar', 1, :tags => ['test'])
+ StatsD.expects(:collect).with(:c, 'values.foobar', 1, :tags => ['test'])
StatsD.increment('values.foobar', :tags => ['test'])
end
def test_statsd_increment_with_multiple_arguments
- StatsD.expects(:collect).with(:incr, 'values.foobar', 12, :sample_rate => nil, :tags => ['test'])
+ StatsD.expects(:collect).with(:c, 'values.foobar', 12, :sample_rate => nil, :tags => ['test'])
StatsD.increment('values.foobar', 12, nil, ['test'])
end
Please sign in to comment.
Something went wrong with that request. Please try again.