Class: ActiveStatsD::Client
- Inherits:
-
Object
- Object
- ActiveStatsD::Client
- Defined in:
- lib/active_statsd/client.rb
Instance Method Summary collapse
- #gauge(metric, value) ⇒ Object
- #increment(metric, by: 1) ⇒ Object
-
#initialize(host:, port:, namespace:) ⇒ Client
constructor
A new instance of Client.
- #timing(metric) ⇒ Object
Constructor Details
#initialize(host:, port:, namespace:) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 |
# File 'lib/active_statsd/client.rb', line 6 def initialize(host:, port:, namespace:) @host = host @port = port @namespace = namespace @socket = UDPSocket.new end |
Instance Method Details
#gauge(metric, value) ⇒ Object
17 18 19 |
# File 'lib/active_statsd/client.rb', line 17 def gauge(metric, value) send_metric("#{metric}:#{value}|g") end |
#increment(metric, by: 1) ⇒ Object
13 14 15 |
# File 'lib/active_statsd/client.rb', line 13 def increment(metric, by: 1) send_metric("#{metric}:#{by}|c") end |
#timing(metric) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/active_statsd/client.rb', line 21 def timing(metric) start_time = Time.now yield ensure duration = ((Time.now - start_time) * 1000).round send_metric("#{metric}:#{duration}|ms") end |