2 class Request::Instrumentation < Faraday::Middleware
3 class Options < Faraday::Options.new(:name, :instrumenter)
5 self[:name] ||= 'request.faraday'
9 self[:instrumenter] ||= ActiveSupport::Notifications
13 # Public: Instruments requests using Active Support.
15 # Measures time spent only for synchronous requests.
19 # ActiveSupport::Notifications.subscribe('request.faraday') do |name, starts, ends, _, env|
21 # http_method = env[:method].to_s.upcase
22 # duration = ends - starts
23 # $stderr.puts '[%s] %s %s (%.3f s)' % [url.host, http_method, url.request_uri, duration]
25 def initialize(app, options = nil)
27 @name, @instrumenter = Options.from(options).values_at(:name, :instrumenter)
31 @instrumenter.instrument(@name, env) do