Class: Nugget::NStatsd

Inherits:
Object
  • Object
show all
Defined in:
lib/nugget/statsd.rb

Overview

NStatsd since Statsd collides

Class Method Summary collapse

Class Method Details

.send_metrics(name, result, response) ⇒ Object



10
11
12
13
14
# File 'lib/nugget/statsd.rb', line 10

def self.send_metrics(name, result, response)
  statsd = Nugget::NStatsd.stats
  send_test_result(statsd, name, result)
  send_test_timings(statsd, name, response)
end

.send_test_result(statsd, name, result) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nugget/statsd.rb', line 16

def self.send_test_result(statsd, name, result)

  if result == "FAIL"
    statsd.gauge("#{name}.failures.count", 1)
    Nugget::Log.debug("Sending the following to statsd: #{name}_failure_count: 1")
  else
    statsd.gauge("#{name}.failures.count", 0)
    Nugget::Log.debug("Sending the following to statsd: #{name}_failure_count: 0")
  end

end

.send_test_timings(statsd, name, response) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/nugget/statsd.rb', line 28

def self.send_test_timings(statsd, name, response)

  response.each do |key, value|
    if key.to_s.include?("_time")
      Nugget::Log.debug("Sending the following to statsd: #{key}: #{value}")
      statsd.timing("#{name}.#{key}", value)
    end
  end

end

.statsObject



4
5
6
7
8
# File 'lib/nugget/statsd.rb', line 4

def self.stats
  @stats ||= Statsd.new(Nugget::Config.statsd_host, Nugget::Config.statsd_port).tap do |statsd|
    statsd.namespace =  Nugget::Config.statsd_namespace
  end
end