class Riemann::Metrics::Client

Constants

CRITICAL
OK
STATES
TTL
WARNING

Public Class Methods

new(host, port, service_name, riemann_env, ttl) click to toggle source
# File lib/riemann/metrics/client.rb, line 14
def initialize host, port, service_name, riemann_env, ttl
  @host = host
  @port = port
  @service_name = service_name
  @ttl = ttl || TTL
  @riemann_env = riemann_env || 'none'
  @hostname = get_hostname
end

Public Instance Methods

client() click to toggle source
# File lib/riemann/metrics/client.rb, line 23
def client
  @riemann_client ||= Riemann::Client.new(host: @host, port: @port)
end
gauge(tags, state, metric, service='', description=nil) click to toggle source
# File lib/riemann/metrics/client.rb, line 27
def gauge tags, state, metric, service='', description=nil
  event = {
    host: @hostname,
    state: state,
    metric: metric,
    ttl: @ttl,
    tags: (tags.dup << @riemann_env),
    service: "#{@service_name}.#{service}"
  }
  event[:description] = description if description
  client << event
end
get_hostname() click to toggle source
# File lib/riemann/metrics/client.rb, line 40
def get_hostname
  `hostname`.strip
end