Class: RailsRiemannMiddleware::Notifier

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Notifier

Returns a new instance of Notifier.



11
12
13
14
15
16
# File 'lib/rails_riemann_middleware.rb', line 11

def initialize(app, options = {})
  @app, @options = app, options
  @send_durations  = options.fetch(:send_durations, true)
  @send_exceptions = options.fetch(:send_exceptions, true)
  @event = Event.new(options)
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



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

def event
  @event
end

#send_durationsObject (readonly)

Returns the value of attribute send_durations.



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

def send_durations
  @send_durations
end

#send_exceptionsObject (readonly)

Returns the value of attribute send_exceptions.



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

def send_exceptions
  @send_exceptions
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/rails_riemann_middleware.rb', line 18

def call(env)
  start_time = Time.now
  @app.call(env)
rescue Exception => exception
  ExceptionNotification.new(event, env, exception).send if send_exceptions
  raise exception
ensure
  Duration.new(event, env, start_time).send if send_durations
end