Sha256: 4ecc895aabbc8f4ecc98e621780c45d351ee992e83d1887943b8f432437c8663
Contents?: true
Size: 1.01 KB
Versions: 20
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require "securerandom" ## # This code is inspired by request_store gem by Steve Klabnik: # # https://github.com/steveklabnik/request_store/ # # See LICENSE.txt in the current directory for the license. module PlainApm module Extensions module Context class Rack def initialize(app) @app = app end def call(env) Context.trace_id = trace_id(env) status, headers, body = @app.call(env) body = if defined?(Rack::BodyProxy) Rack::BodyProxy.new(body) do Context.clear! end else body end processed = true [status, headers, body] ensure Context.clear! if !processed end private def trace_id(env) request_id(env) || SecureRandom.uuid end def request_id(env) env["action_dispatch.request_id"] || env["HTTP_X_REQUEST_ID"] end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems