Welcome to mirror list, hosted at ThFree Co, Russian Federation.

correlation_id.rb « middleware « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80dddc41c122af7ba54a90df8484392dcb5620d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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)
        request(env).request_id
      end

      def request(env)
        ActionDispatch::Request.new(env)
      end
    end
  end
end