Sha256: d023c0f9fe9768deb4104afe16513a8406d6a84ecd675e8e3417759e8bace92b

Contents?: true

Size: 1.01 KB

Versions: 89

Compression:

Stored size: 1.01 KB

Contents

module Faraday
  class Request::Instrumentation < Faraday::Middleware
    class Options < Faraday::Options.new(:name, :instrumenter)
      def name
        self[:name] ||= 'request.faraday'
      end

      def instrumenter
        self[:instrumenter] ||= ActiveSupport::Notifications
      end
    end

    # Public: Instruments requests using Active Support.
    #
    # Measures time spent only for synchronous requests.
    #
    # Examples
    #
    #   ActiveSupport::Notifications.subscribe('request.faraday') do |name, starts, ends, _, env|
    #     url = env[:url]
    #     http_method = env[:method].to_s.upcase
    #     duration = ends - starts
    #     $stderr.puts '[%s] %s %s (%.3f s)' % [url.host, http_method, url.request_uri, duration]
    #   end
    def initialize(app, options = nil)
      super(app)
      @name, @instrumenter = Options.from(options).values_at(:name, :instrumenter)
    end

    def call(env)
      @instrumenter.instrument(@name, env) do
        @app.call(env)
      end
    end
  end
end

Version data entries

89 entries across 81 versions & 10 rubygems

Version Path
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.9 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.8 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.7 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/faraday-0.17.4/lib/faraday/request/instrumentation.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/faraday-0.17.3/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.6 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/faraday-0.17.3/lib/faraday/request/instrumentation.rb
faraday-0.17.4 lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/faraday-0.17.0/lib/faraday/request/instrumentation.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/request/instrumentation.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/faraday-0.17.0/lib/faraday/request/instrumentation.rb
faraday-0.17.3 lib/faraday/request/instrumentation.rb
tdiary-5.1.0 vendor/bundle/gems/faraday-0.17.1/lib/faraday/request/instrumentation.rb
faraday-0.17.1 lib/faraday/request/instrumentation.rb
faraday-0.17.0 lib/faraday/request/instrumentation.rb