Class: GrapeRailsLogger::DebugTracer
- Inherits:
-
Grape::Middleware::Base
- Object
- Grape::Middleware::Base
- GrapeRailsLogger::DebugTracer
- Defined in:
- lib/grape_rails_logger/debug_tracer.rb
Overview
Optional middleware for detailed request tracing when TRACE env var is set
Requires the ‘debug’ gem to be installed. If TRACE is not set or Debug class is unavailable, this middleware passes through without tracing.
This middleware is completely exception-safe: any error in tracing will cause the middleware to pass through without tracing, never breaking requests.
Constant Summary collapse
- TRACE_ENABLED =
ENV["TRACE"]
Instance Method Summary collapse
Instance Method Details
#call!(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/grape_rails_logger/debug_tracer.rb', line 17 def call!(env) # Fast path: if TRACE not enabled, pass through immediately return @app.call(env) unless TRACE_ENABLED # Try to trace, but if anything fails, just pass through trace_request(env) do @app.call(env) end rescue => e # If tracing fails for any reason, log and pass through # Never break the request flow log_trace_error(e) @app.call(env) end |