Sha256: b2b61dad2079032045e2c4379ea9c64cc2f6ee9b205e76e5148e07ce03b2437d

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

require_relative 'base'
require_relative '../trace'
require 'faraday'

module RequestTracer
  module Integration
    module FaradayHandler
      extend self
      def activate
        ::Faraday::Request.register_middleware(nil, tracing: FaradayTracing)
        builder = Faraday::RackBuilder.new
        builder.insert 0, FaradayTracing
        Faraday.default_connection_options.builder = builder
      end
    end
    class FaradayTracing < ::Faraday::Middleware
      include Base
      def call(env)
        Trace.record do |trace|
          env[:request_headers].merge!(extract_headers_from_fields(trace))
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
request-tracer-0.6.6 lib/request_tracer/integration/faraday_handler.rb