Class: LogStruct::Integrations::RequestContext::Middleware
- Inherits:
-
LogStruct::Integrations::RackMiddleware
- Object
- LogStruct::Integrations::RackMiddleware
- LogStruct::Integrations::RequestContext::Middleware
- Defined in:
- lib/log_struct/integrations/request_context/middleware.rb
Overview
Middleware that captures request_id and stores it in SemanticLogger's named_tags so all logs during the request include the request_id.
Instance Method Summary collapse
Methods inherited from LogStruct::Integrations::RackMiddleware
Constructor Details
This class inherits a constructor from LogStruct::Integrations::RackMiddleware
Instance Method Details
#call(env) ⇒ T.untyped
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/log_struct/integrations/request_context/middleware.rb', line 13 def call(env) request = ::ActionDispatch::Request.new(env) request_id = request.request_id Thread.current[:logstruct_request_id] = request_id ::SemanticLogger.(request_id: request_id) @app.call(env) ensure ::SemanticLogger. Thread.current[:logstruct_request_id] = nil end |