module OneApm module Agent module Instrumentation module Rack include TransactionBase def oneapm_request_headers(_) @oneapm_request.env end def call_with_oneapm(*args) @oneapm_request = ::Rack::Request.new(args.first) perform_action_with_oneapm_trace(:category => :middleware, :request => @oneapm_request) do result = call_without_oneapm(*args) # Ignore cascaded calls Transaction.abort_transaction! if result.first == 404 result end end def self.included middleware middleware.class_eval do alias call_without_oneapm call alias call call_with_oneapm end end def self.extended middleware middleware.class_eval do class << self alias call_without_oneapm call alias call call_with_oneapm end end end def _oa_has_middleware_tracing true end end end end end