Class: Statsd
- Inherits:
-
Object
- Object
- Statsd
- Defined in:
- lib/statsd.rb
Overview
Statsd: A Statsd client (github.com/etsy/statsd)
Example:
statsd = Statsd.new 'localhost', 8125
statsd.increment 'garets'
statsd.timing 'glork', 320
Instance Attribute Summary collapse
-
#namespace ⇒ Object
Returns the value of attribute namespace.
Instance Method Summary collapse
- #count(stat, count, sample_rate = 1) ⇒ Object
- #decrement(stat, sample_rate = 1) ⇒ Object
- #increment(stat, sample_rate = 1) ⇒ Object
-
#initialize(host, port = 8125) ⇒ Statsd
constructor
A new instance of Statsd.
- #time(stat, sample_rate = 1) ⇒ Object
- #timing(stat, ms, sample_rate = 1) ⇒ Object
Constructor Details
#initialize(host, port = 8125) ⇒ Statsd
Returns a new instance of Statsd.
16 17 18 |
# File 'lib/statsd.rb', line 16 def initialize(host, port=8125) @host, @port = host, port end |
Instance Attribute Details
#namespace ⇒ Object
Returns the value of attribute namespace.
12 13 14 |
# File 'lib/statsd.rb', line 12 def namespace @namespace end |
Instance Method Details
#count(stat, count, sample_rate = 1) ⇒ Object
31 |
# File 'lib/statsd.rb', line 31 def count(stat, count, sample_rate=1); send stat, count, 'c', sample_rate end |
#decrement(stat, sample_rate = 1) ⇒ Object
26 |
# File 'lib/statsd.rb', line 26 def decrement(stat, sample_rate=1); count stat, -1, sample_rate end |
#increment(stat, sample_rate = 1) ⇒ Object
22 |
# File 'lib/statsd.rb', line 22 def increment(stat, sample_rate=1); count stat, 1, sample_rate end |
#time(stat, sample_rate = 1) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/statsd.rb', line 38 def time(stat, sample_rate=1) start = Time.now result = yield timing(stat, ((Time.now - start) * 1000).round, sample_rate) result end |
#timing(stat, ms, sample_rate = 1) ⇒ Object
36 |
# File 'lib/statsd.rb', line 36 def timing(stat, ms, sample_rate=1); send stat, ms, 'ms', sample_rate end |