Sha256: 13971c647e0e176c5df1244348a33126c202a0f714872b4b33d034f15c8d0a3a

Contents?: true

Size: 729 Bytes

Versions: 15

Compression:

Stored size: 729 Bytes

Contents

# frozen_string_literals: true

module Lumberjack
  module Rack
    # Support for using the Rails ActionDispatch request id in the log.
    # The format is expected to be a random UUID and only the first chunk is used for terseness
    # if the abbreviated argument is true.
    class RequestId
      REQUEST_ID = "action_dispatch.request_id"

      def initialize(app, abbreviated = false)
        @app = app
        @abbreviated = abbreviated
      end

      def call(env)
        request_id = env[REQUEST_ID]
        if request_id && @abbreviated
          request_id = request_id.split("-", 2).first
        end
        Lumberjack.unit_of_work(request_id) do
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/lumberjack-1.2.9/lib/lumberjack/rack/request_id.rb
lumberjack-1.2.9 lib/lumberjack/rack/request_id.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.28 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.27 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.26 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
qiita_org-0.1.25 gems/ruby/2.7.0/gems/lumberjack-1.2.8/lib/lumberjack/rack/request_id.rb
lumberjack-1.2.8 lib/lumberjack/rack/request_id.rb