class RailsRiemannMiddleware::Event

Attributes

client[R]
options[R]
reporting_host[R]
tags[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/rails_riemann_middleware/event.rb, line 8
def initialize(options={})
  @options         = options
  @client          = create_riemann_client
  @reporting_host  = options[:reporting_host]
  @tags            = options.fetch(:tags, [])
  @attributes      = options.fetch(:attributes, {})
end

Public Instance Methods

<<(msg) click to toggle source
# File lib/rails_riemann_middleware/event.rb, line 16
def <<(msg)
  msg[:tags] += Array(tags)
  client << {:time => time_for_client, :host => reporting_host}.merge(@attributes).merge(msg)
end
app_prefix() click to toggle source
# File lib/rails_riemann_middleware/event.rb, line 21
def app_prefix
  options.fetch(:app_prefix, "")
end

Private Instance Methods

create_riemann_client() click to toggle source
# File lib/rails_riemann_middleware/event.rb, line 31
def create_riemann_client
  riemann_host    = options.fetch(:riemann_host, "127.0.0.1")
  riemann_port    = options.fetch(:riemann_port, "5555")

  Riemann::Client.new(:host => riemann_host, :port => riemann_port)
end
time_for_client() click to toggle source
# File lib/rails_riemann_middleware/event.rb, line 27
def time_for_client
  Time.now.to_i - 10
end