Class: GoogleCloudRun::RequestId
- Inherits:
-
Object
- Object
- GoogleCloudRun::RequestId
- Defined in:
- lib/google_cloud_run/request_id.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
A middleware to replace X-Request-Id with X-Cloud-Trace-Context’s Trace ID ref: github.com/rails/rails/blob/6-1-stable/actionpack/lib/action_dispatch/middleware/request_id.rb ref: github.com/Octo-Labs/heroku-request-id/blob/master/lib/heroku-request-id/railtie.rb.
-
#initialize(app) ⇒ RequestId
constructor
A new instance of RequestId.
Constructor Details
#initialize(app) ⇒ RequestId
Returns a new instance of RequestId.
3 4 5 |
# File 'lib/google_cloud_run/request_id.rb', line 3 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
A middleware to replace X-Request-Id with X-Cloud-Trace-Context’s Trace ID ref: github.com/rails/rails/blob/6-1-stable/actionpack/lib/action_dispatch/middleware/request_id.rb ref: github.com/Octo-Labs/heroku-request-id/blob/master/lib/heroku-request-id/railtie.rb
10 11 12 13 14 |
# File 'lib/google_cloud_run/request_id.rb', line 10 def call(env) req = ActionDispatch::Request.new env trace, _, _ = GoogleCloudRun.parse_trace_context(req.headers["X-Cloud-Trace-Context"]) @app.call(env).tap { |_status, headers, _body| headers["X-Request-Id"] = trace } end |