Class: Statsd
- Inherits:
-
Object
- Object
- Statsd
- Defined in:
- lib/statsd.rb
Instance Method Summary collapse
- #dec(stat, delta = 1) ⇒ Object
- #inc(stat, delta = 1) ⇒ Object
-
#initialize(host = "localhost", port = 8125) ⇒ Statsd
constructor
A new instance of Statsd.
- #mark(stat, count = 1) ⇒ Object
- #time(stat) ⇒ Object
Constructor Details
#initialize(host = "localhost", port = 8125) ⇒ Statsd
Returns a new instance of Statsd.
5 6 7 8 9 |
# File 'lib/statsd.rb', line 5 def initialize(host = "localhost", port = 8125) @host = host @port = port @socket = UDPSocket.new end |
Instance Method Details
#dec(stat, delta = 1) ⇒ Object
22 23 24 |
# File 'lib/statsd.rb', line 22 def dec(stat, delta = 1) announce :action => "dec", :delta => delta, :name => stat end |
#inc(stat, delta = 1) ⇒ Object
18 19 20 |
# File 'lib/statsd.rb', line 18 def inc(stat, delta = 1) announce :action => "inc", :delta => delta, :name => stat end |
#mark(stat, count = 1) ⇒ Object
26 27 28 |
# File 'lib/statsd.rb', line 26 def mark(stat, count = 1) announce :action => "mark", :count => count, :name => stat end |
#time(stat) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/statsd.rb', line 11 def time(stat) start = Time.now result = yield timing(stat, ((Time.now - start) * 1000).round) result end |