Class: RailsRiemannMiddleware::Notifier
- Inherits:
-
Object
- Object
- RailsRiemannMiddleware::Notifier
- Defined in:
- lib/rails_riemann_middleware.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#send_durations ⇒ Object
readonly
Returns the value of attribute send_durations.
-
#send_exceptions ⇒ Object
readonly
Returns the value of attribute send_exceptions.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Notifier
constructor
A new instance of Notifier.
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, = {}) @app, @options = app, @send_durations = .fetch(:send_durations, true) @send_exceptions = .fetch(:send_exceptions, true) @event = Event.new() end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
9 10 11 |
# File 'lib/rails_riemann_middleware.rb', line 9 def event @event end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/rails_riemann_middleware.rb', line 9 def @options end |
#send_durations ⇒ Object (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_exceptions ⇒ Object (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 |