Class: Atatus::Middleware Private
- Inherits:
-
Object
- Object
- Atatus::Middleware
- Includes:
- Logging
- Defined in:
- lib/atatus/middleware.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Instance Method Summary collapse
- #call(env) ⇒ Object private
-
#initialize(app) ⇒ Middleware
constructor
private
A new instance of Middleware.
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(app) ⇒ Middleware
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Middleware.
26 27 28 |
# File 'lib/atatus/middleware.rb', line 26 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/atatus/middleware.rb', line 30 def call(env) begin if running? && !path_ignored?(env) transaction = start_transaction(env) end resp = @app.call env rescue InternalError raise # Don't report Atatus errors rescue ::Exception => e context = Atatus.build_context(rack_env: env, for_type: :error) Atatus.report(e, context: context, handled: false) raise ensure if transaction if resp status, headers, _body = resp transaction.add_response(status, headers: headers.dup) transaction&.outcome = Transaction::Outcome.from_http_status(status) else transaction&.outcome = Transaction::Outcome::FAILURE end end Atatus.end_transaction http_result(status) end resp end |