Class: RailsRiemannMiddleware::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_riemann_middleware/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Event

Returns a new instance of Event.



8
9
10
11
12
13
14
# 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

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/rails_riemann_middleware/event.rb', line 6

def client
  @client
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/rails_riemann_middleware/event.rb', line 6

def options
  @options
end

#reporting_hostObject (readonly)

Returns the value of attribute reporting_host.



6
7
8
# File 'lib/rails_riemann_middleware/event.rb', line 6

def reporting_host
  @reporting_host
end

#tagsObject (readonly)

Returns the value of attribute tags.



6
7
8
# File 'lib/rails_riemann_middleware/event.rb', line 6

def tags
  @tags
end

Instance Method Details

#<<(msg) ⇒ Object



16
17
18
19
# 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_prefixObject



21
22
23
# File 'lib/rails_riemann_middleware/event.rb', line 21

def app_prefix
  options.fetch(:app_prefix, "")
end