Class: NatsWork::Monitoring::StatsDReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/natswork/monitoring.rb

Overview

StatsD integration

Instance Method Summary collapse

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

#closeObject



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, tags = {})
  send_metric("#{@prefix}.#{metric}", value, 'c', tags)
end

#report_gauge(metric, value, tags = {}) ⇒ Object



111
112
113
# File 'lib/natswork/monitoring.rb', line 111

def report_gauge(metric, value, tags = {})
  send_metric("#{@prefix}.#{metric}", value, 'g', tags)
end

#report_histogram(metric, value, tags = {}) ⇒ Object



119
120
121
# File 'lib/natswork/monitoring.rb', line 119

def report_histogram(metric, value, tags = {})
  send_metric("#{@prefix}.#{metric}", value, 'h', tags)
end

#report_timer(metric, value, tags = {}) ⇒ Object



115
116
117
# File 'lib/natswork/monitoring.rb', line 115

def report_timer(metric, value, tags = {})
  send_metric("#{@prefix}.#{metric}", value, 'ms', tags)
end