Class: Logtide::Rack::Middleware
- Inherits:
-
Object
- Object
- Logtide::Rack::Middleware
- Defined in:
- lib/logtide/rack/middleware.rb
Overview
Rack middleware (spec 004 section 6). Per request it clones the hub for isolation, reads the inbound traceparent, tags the scope, records request and response breadcrumbs, emits a request log, and captures unhandled exceptions before re-raising them (it never swallows errors).
Constant Summary collapse
- DEFAULT_SKIP_PATHS =
%w[/health /healthz].freeze
- SENSITIVE_HEADERS =
Redacted by default so secrets never reach captured data (spec 004 section 6).
%w[ authorization cookie set-cookie x-api-key x-auth-token proxy-authorization ].freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, skip_paths: DEFAULT_SKIP_PATHS, capture_request_logs: true) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, skip_paths: DEFAULT_SKIP_PATHS, capture_request_logs: true) ⇒ Middleware
Returns a new instance of Middleware.
17 18 19 20 21 |
# File 'lib/logtide/rack/middleware.rb', line 17 def initialize(app, skip_paths: DEFAULT_SKIP_PATHS, capture_request_logs: true) @app = app @skip_paths = skip_paths @capture_request_logs = capture_request_logs end |
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/logtide/rack/middleware.rb', line 23 def call(env) path = env["PATH_INFO"].to_s return @app.call(env) if @skip_paths.include?(path) Logtide.with_request_hub do |hub| start = monotonic setup_scope(hub, env) handle(hub, env, start) end end |