Class: RailsRiemannMiddleware::ExceptionNotification

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event, env, exception, options = {}) ⇒ ExceptionNotification

Returns a new instance of ExceptionNotification.



8
9
10
11
# File 'lib/rails_riemann_middleware/exception_notification.rb', line 8

def initialize(event, env, exception, options={})
  @event, @env, @exception = event, env, exception
  @headers = options.fetch(:headers, [])
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



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

def env
  @env
end

#eventObject (readonly)

Returns the value of attribute event.



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

def event
  @event
end

#exceptionObject (readonly)

Returns the value of attribute exception.



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

def exception
  @exception
end

#headersObject (readonly)

Returns the value of attribute headers.



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

def headers
  @headers
end

Instance Method Details

#deliverObject



17
18
19
# File 'lib/rails_riemann_middleware/exception_notification.rb', line 17

def deliver
  send
end

#messageObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_riemann_middleware/exception_notification.rb', line 21

def message
  msg = {
    :host        => env['HTTP_HOST'],
    :service     => "#{event.app_prefix} exception".strip,
    :state       => 'error',
    :description => backtrace,
    :tags        => ["exception"]
  }
  # ap msg
  msg
end

#sendObject



13
14
15
# File 'lib/rails_riemann_middleware/exception_notification.rb', line 13

def send
  event << message
end