Permalink
Browse files

Make sure that colon in a metric's name is replaced by dot

  • Loading branch information...
camilo committed Oct 9, 2012
1 parent 03adcbe commit 1a0c3b08ca90fa06e2fcb46a877432d94ccdde8c
Showing with 11 additions and 0 deletions.
  1. +2 −0 lib/statsd/instrument.rb
  2. +9 −0 test/statsd-instrument_test.rb
View
@@ -131,6 +131,8 @@ def self.write(k,v,op, sample_rate = default_sample_rate)
return unless enabled
return if sample_rate < 1 && rand > sample_rate
+ k = k.gsub('::', '.')
+
command = "#{self.prefix + '.' if self.prefix}#{k}:#{v}"
case op
when :incr
@@ -136,6 +136,15 @@ def test_statsd_count_with_method_receiving_block
assert_equal 'block called', return_value
end
+ def test_statsd_measure_with_nested_modules
+ ActiveMerchant::UniqueGateway.statsd_measure :ssl_post, 'ActiveMerchant::Gateway.ssl_post'
+
+ StatsD.stubs(:mode).returns(:production)
+ UDPSocket.any_instance.expects(:send).with(regexp_matches(/ActiveMerchant\.Gateway\.ssl_post:\d\.\d{2,}\|ms/), 0, 'localhost', 123).at_least(1)
+
+ ActiveMerchant::UniqueGateway.new.purchase(true)
+ end
+
def test_statsd_measure
ActiveMerchant::UniqueGateway.statsd_measure :ssl_post, 'ActiveMerchant.Gateway.ssl_post'

0 comments on commit 1a0c3b0

Please sign in to comment.