Class: SimpleMetrics::Client
- Inherits:
-
Object
- Object
- SimpleMetrics::Client
- Defined in:
- lib/simple_metrics/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
-
#count(stat, count, sample_rate = 1) ⇒ Object
send relative value.
-
#gauge(stat, value) ⇒ Object
send absolute value.
-
#increment(stat, sample_rate = 1) ⇒ Object
send relative value.
-
#initialize(host, port = 8125) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(host, port = 8125) ⇒ Client
Returns a new instance of Client.
18 19 20 |
# File 'lib/simple_metrics/client.rb', line 18 def initialize(host, port = 8125) @host, @port = host, port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/simple_metrics/client.rb', line 8 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/simple_metrics/client.rb', line 8 def port @port end |
Class Method Details
.logger ⇒ Object
14 15 16 |
# File 'lib/simple_metrics/client.rb', line 14 def self.logger @@logger ||= Logger.new($stdout) end |
.logger=(logger) ⇒ Object
10 11 12 |
# File 'lib/simple_metrics/client.rb', line 10 def self.logger=(logger) @@logger = logger end |
Instance Method Details
#count(stat, count, sample_rate = 1) ⇒ Object
send relative value
28 29 30 |
# File 'lib/simple_metrics/client.rb', line 28 def count(stat, count, sample_rate = 1) send_data( stat, count, 'c', sample_rate) end |
#gauge(stat, value) ⇒ Object
send absolute value
33 34 35 |
# File 'lib/simple_metrics/client.rb', line 33 def gauge(stat, value) send_data(stat, value, 'g') end |
#increment(stat, sample_rate = 1) ⇒ Object
send relative value
23 24 25 |
# File 'lib/simple_metrics/client.rb', line 23 def increment(stat, sample_rate = 1) count(stat, 1, sample_rate) end |