Class: GrapeRailsLogger::DebugTracer
- Inherits:
-
Grape::Middleware::Base
- Object
- Grape::Middleware::Base
- GrapeRailsLogger::DebugTracer
- Defined in:
- lib/grape_rails_logger/debug_tracer.rb,
sig/grape_rails_logger.rbs
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.
Instance Method Summary collapse
Instance Method Details
#call!(env) ⇒ Array[Integer, Hash[String, String], Array[String]]
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/grape_rails_logger/debug_tracer.rb', line 15 def call!(env) # Read TRACE at call time so process env (and test ClimateControl) apply after load return @app.call(env) unless ENV["TRACE"] # 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 |