Class: Bugwatch::Middleware
- Inherits:
-
Object
- Object
- Bugwatch::Middleware
- Defined in:
- lib/bugwatch/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
3 4 5 |
# File 'lib/bugwatch/middleware.rb', line 3 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bugwatch/middleware.rb', line 7 def call(env) start = Process.clock_gettime(Process::CLOCK_MONOTONIC) BreadcrumbCollector.clear UserContext.clear begin status, headers, body = @app.call(env) record_transaction(env, status, start) [status, headers, body] rescue Exception => e # rubocop:disable Lint/RescueException duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).round unless Bugwatch.configuration.ignore?(e) payload = ErrorBuilder.new(e, env).build payload[:duration_ms] = duration_ms Notification.new(payload).deliver end record_transaction(env, 500, start) raise end end |