gitlab-org--gitlab-foss/lib/gitlab/middleware/correlation_id.rb

32 lines
599 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# A dumb middleware that steals correlation id
# and sets it as a global context for the request
module Gitlab
module Middleware
class CorrelationId
include ActionView::Helpers::TagHelper
def initialize(app)
@app = app
end
def call(env)
::Gitlab::CorrelationId.use_id(correlation_id(env)) do
@app.call(env)
end
end
private
def correlation_id(env)
2018-12-15 04:06:56 -05:00
request(env).request_id
end
def request(env)
ActionDispatch::Request.new(env)
end
end
end
end