Class: NatsWork::Monitoring::StatsDReporter
- Inherits:
-
Object
- Object
- NatsWork::Monitoring::StatsDReporter
- Defined in:
- lib/natswork/monitoring.rb
Overview
StatsD integration
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(host = 'localhost', port = 8125, prefix = 'natswork') ⇒ StatsDReporter
constructor
A new instance of StatsDReporter.
- #report_counter(metric, value, tags = {}) ⇒ Object
- #report_gauge(metric, value, tags = {}) ⇒ Object
- #report_histogram(metric, value, tags = {}) ⇒ Object
- #report_timer(metric, value, tags = {}) ⇒ Object
Constructor Details
#initialize(host = 'localhost', port = 8125, prefix = 'natswork') ⇒ StatsDReporter
Returns a new instance of StatsDReporter.
100 101 102 103 104 105 |
# File 'lib/natswork/monitoring.rb', line 100 def initialize(host = 'localhost', port = 8125, prefix = 'natswork') @host = host @port = port @prefix = prefix @socket = UDPSocket.new end |
Instance Method Details
#close ⇒ Object
123 124 125 |
# File 'lib/natswork/monitoring.rb', line 123 def close @socket.close end |
#report_counter(metric, value, tags = {}) ⇒ Object
107 108 109 |
# File 'lib/natswork/monitoring.rb', line 107 def report_counter(metric, value, = {}) send_metric("#{@prefix}.#{metric}", value, 'c', ) end |
#report_gauge(metric, value, tags = {}) ⇒ Object
111 112 113 |
# File 'lib/natswork/monitoring.rb', line 111 def report_gauge(metric, value, = {}) send_metric("#{@prefix}.#{metric}", value, 'g', ) end |
#report_histogram(metric, value, tags = {}) ⇒ Object
119 120 121 |
# File 'lib/natswork/monitoring.rb', line 119 def report_histogram(metric, value, = {}) send_metric("#{@prefix}.#{metric}", value, 'h', ) end |
#report_timer(metric, value, tags = {}) ⇒ Object
115 116 117 |
# File 'lib/natswork/monitoring.rb', line 115 def report_timer(metric, value, = {}) send_metric("#{@prefix}.#{metric}", value, 'ms', ) end |