statsd-instrument 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/statsd/instrument.rb +3 -3
- data/statsd-instrument.gemspec +1 -1
- data/test/statsd-instrument_test.rb +8 -2
- metadata +3 -3
data/lib/statsd/instrument.rb
CHANGED
@@ -15,7 +15,7 @@ module StatsD
|
|
15
15
|
:prefix, :implementation
|
16
16
|
end
|
17
17
|
self.enabled = true
|
18
|
-
self.default_sample_rate = 1
|
18
|
+
self.default_sample_rate = 1.0
|
19
19
|
self.implementation = :statsd
|
20
20
|
|
21
21
|
TimeoutClass = defined?(::SystemTimer) ? ::SystemTimer : ::Timeout
|
@@ -100,13 +100,13 @@ module StatsD
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# glork:320|ms
|
103
|
-
def self.measure(key, milli = nil)
|
103
|
+
def self.measure(key, milli = nil, sample_rate = default_sample_rate)
|
104
104
|
result = nil
|
105
105
|
ms = milli || Benchmark.ms do
|
106
106
|
result = yield
|
107
107
|
end
|
108
108
|
|
109
|
-
write(key, ms, :ms)
|
109
|
+
write(key, ms, :ms, sample_rate)
|
110
110
|
result
|
111
111
|
end
|
112
112
|
|
data/statsd-instrument.gemspec
CHANGED
@@ -139,7 +139,7 @@ class StatsDTest < Test::Unit::TestCase
|
|
139
139
|
def test_statsd_measure
|
140
140
|
ActiveMerchant::UniqueGateway.statsd_measure :ssl_post, 'ActiveMerchant.Gateway.ssl_post'
|
141
141
|
|
142
|
-
StatsD.expects(:write).with('ActiveMerchant.Gateway.ssl_post', is_a(Float), :ms).returns({:success => true})
|
142
|
+
StatsD.expects(:write).with('ActiveMerchant.Gateway.ssl_post', is_a(Float), :ms, is_a(Numeric)).returns({:success => true})
|
143
143
|
ActiveMerchant::UniqueGateway.new.purchase(true)
|
144
144
|
end
|
145
145
|
|
@@ -257,11 +257,17 @@ class StatsDTest < Test::Unit::TestCase
|
|
257
257
|
end
|
258
258
|
|
259
259
|
def test_statsd_measure_with_explicit_value
|
260
|
-
StatsD.expects(:write).with('values.foobar', 42, :ms)
|
260
|
+
StatsD.expects(:write).with('values.foobar', 42, :ms, is_a(Numeric))
|
261
261
|
|
262
262
|
StatsD.measure('values.foobar', 42)
|
263
263
|
end
|
264
264
|
|
265
|
+
def test_statsd_measure_with_explicit_value_and_sample_rate
|
266
|
+
StatsD.expects(:write).with('values.foobar', 42, :ms, 0.1)
|
267
|
+
|
268
|
+
StatsD.measure('values.foobar', 42, 0.1)
|
269
|
+
end
|
270
|
+
|
265
271
|
def test_statsd_gauge
|
266
272
|
StatsD.expects(:write).with('values.foobar', 12, :g, 1)
|
267
273
|
|
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: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-07-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mocha
|
16
|
-
requirement: &
|
16
|
+
requirement: &2170660100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2170660100
|
25
25
|
description: A StatsD client for Ruby apps. Provides metaprogramming methods to inject
|
26
26
|
StatsD instrumentation into your code.
|
27
27
|
email:
|