Class: JenkinsStatsd::StatsdClient

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins_statsd/statsd_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, namespace) ⇒ StatsdClient

Returns a new instance of StatsdClient.



6
7
8
# File 'lib/jenkins_statsd/statsd_client.rb', line 6

def initialize(host, port, namespace)
  @statsd = Statsd.new(host, port).tap { |sd| sd.namespace = namespace }
end

Instance Attribute Details

#statsdObject (readonly)

Returns the value of attribute statsd.



5
6
7
# File 'lib/jenkins_statsd/statsd_client.rb', line 5

def statsd
  @statsd
end

Instance Method Details

#send_metrics(metrics) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jenkins_statsd/statsd_client.rb', line 10

def send_metrics(metrics)
  metrics[:gauges].each do |key, value|
    statsd.gauge(key, value)
  end

  metrics[:meters].each do |key, value|
    statsd.gauge(key, value)
  end

  metrics[:timers].each do |key, value|
    statsd.gauge(key, value)
  end
end