Class: Graphite
- Inherits:
-
Object
- Object
- Graphite
- Defined in:
- lib/graphite.rb
Instance Method Summary collapse
-
#initialize(token, host, port = 2003) ⇒ Graphite
constructor
A new instance of Graphite.
- #measure(stat, value = nil) ⇒ Object
Constructor Details
#initialize(token, host, port = 2003) ⇒ Graphite
Returns a new instance of Graphite.
4 5 6 |
# File 'lib/graphite.rb', line 4 def initialize(token, host, port = 2003) @token, @host, @port = token, host, port end |
Instance Method Details
#measure(stat, value = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/graphite.rb', line 8 def measure(stat, value = nil) if block_given? start = Time.now yield value = ((Time.now - start) * 1000).round end send_to_socket("#{stat} #{value}") unless value.nil? end |