Class: HttpStatsd::Client
- Inherits:
-
Object
- Object
- HttpStatsd::Client
- Includes:
- HTTParty
- Defined in:
- lib/http_statsd/client.rb
Defined Under Namespace
Classes: BatchOperation
Instance Method Summary collapse
- #batch {|batch_operation| ... } ⇒ Object
- #count(name, value, sample_rate = nil) ⇒ Object
- #decrement(name, sample_rate = nil) ⇒ Object
- #gauge(name, value) ⇒ Object
- #increment(name, sample_rate = nil) ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #timing(name, value, sample_rate = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/http_statsd/client.rb', line 7 def initialize(opts = {}) @base_uri = opts[:base_uri] @auth = {:username => opts[:username], :password => opts[:password]} end |
Instance Method Details
#batch {|batch_operation| ... } ⇒ Object
41 42 43 44 45 |
# File 'lib/http_statsd/client.rb', line 41 def batch batch_operation = BatchOperation.new yield batch_operation post(:batch, {:metrics => batch_operation.metrics.join("\n")}) end |
#count(name, value, sample_rate = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/http_statsd/client.rb', line 24 def count(name, value, sample_rate = nil) query = {:name => name, :value => value} query.merge!({:sample_rate => sample_rate}) if sample_rate get(:count, query) end |
#decrement(name, sample_rate = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/http_statsd/client.rb', line 18 def decrement(name, sample_rate = nil) query = {:name => name} query.merge!({:sample_rate => sample_rate}) if sample_rate get(:decrement, query) end |
#gauge(name, value) ⇒ Object
30 31 32 33 |
# File 'lib/http_statsd/client.rb', line 30 def gauge(name, value) query = {:name => name, :value => value} get(:gauge, query) end |
#increment(name, sample_rate = nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/http_statsd/client.rb', line 12 def increment(name, sample_rate = nil) query = {:name => name} query.merge!({:sample_rate => sample_rate}) if sample_rate get(:increment, query) end |
#timing(name, value, sample_rate = nil) ⇒ Object
35 36 37 38 39 |
# File 'lib/http_statsd/client.rb', line 35 def timing(name, value, sample_rate = nil) query = {:name => name, :value => value} query.merge!({:sample_rate => sample_rate}) if sample_rate get(:timing, query) end |