class Vitals::Reporters::RiemannReporter

Attributes

format[RW]
riemann[R]

Public Class Methods

new(host: 'localhost', port: 5555, timeout: 5, format: nil, facility: nil, environment: nil) click to toggle source
# File lib/vitals/riemann_reporter.rb, line 12
def initialize(host: 'localhost', port: 5555, timeout: 5, format: nil, facility: nil, environment: nil)
  @riemann = Riemann::Client.new(host: host, port: port, timeout: timeout)
  @format = format
  @facility = facility
  @environment = environment
end

Public Instance Methods

count(m, v) click to toggle source
# File lib/vitals/riemann_reporter.rb, line 27
def count(m, v)
  emit(format.format(m), v, 'counter')
end
gauge(m, v) click to toggle source
# File lib/vitals/riemann_reporter.rb, line 23
def gauge(m, v)
  emit(format.format(m), v, 'gauge')
end
inc(m) click to toggle source
# File lib/vitals/riemann_reporter.rb, line 19
def inc(m)
  emit(format.format(m), 1, 'counter')
end
timing(m, v) click to toggle source
# File lib/vitals/riemann_reporter.rb, line 31
def timing(m, v)
  emit(format.format(m), v, 'timer')
end

Private Instance Methods

emit(m, v, type) click to toggle source
# File lib/vitals/riemann_reporter.rb, line 36
def emit(m, v, type)
  @riemann << {
    service: m,
    metric: v,
    time: Time.now.to_i,
    tags: ['vitals', type],
    facility: @facility,
    environment: @environment
  }
end