Class: AppPerfRpm::Middleware
- Inherits:
-
Object
- Object
- AppPerfRpm::Middleware
- Defined in:
- lib/app_perf_rpm/middleware.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #handle_exception(env, exception) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 |
# File 'lib/app_perf_rpm/middleware.rb', line 5 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
3 4 5 |
# File 'lib/app_perf_rpm/middleware.rb', line 3 def app @app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/app_perf_rpm/middleware.rb', line 9 def call(env) begin @status, @headers, @response = @app.call(env) rescue Exception => e handle_exception(env, e) end [@status, @headers, @response] end |
#handle_exception(env, exception) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/app_perf_rpm/middleware.rb', line 18 def handle_exception(env, exception) ::AppPerfRpm::Tracer.log_event("error", "path" => env["PATH_INFO"], "method" => env["REQUEST_METHOD"], "message" => exception., "error_class" => exception.class.to_s, "backtrace" => ::AppPerfRpm::Backtrace.clean(exception.backtrace), "source" => ::AppPerfRpm::Backtrace.source_extract(exception.backtrace) ) raise exception end |