Sha256: baa201e40be5adc02b0e1c8eabf37918434e60350f3f4b93096403056ae2f2c5

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

module Excon
  module Middleware
    class Instrumentor < Excon::Middleware::Base
      def error_call(datum)
        if datum.has_key?(:instrumentor)
          datum[:instrumentor].instrument("#{datum[:instrumentor_name]}.error", :error => datum[:error]) do
            @stack.error_call(datum)
          end
        else
          @stack.error_call(datum)
        end
      end

      def request_call(datum)
        if datum.has_key?(:instrumentor)
          if datum[:retries_remaining] < datum[:retry_limit]
            event_name = "#{datum[:instrumentor_name]}.retry"
          else
            event_name = "#{datum[:instrumentor_name]}.request"
          end
          datum[:instrumentor].instrument(event_name, datum) do
            @stack.request_call(datum)
          end
        else
          @stack.request_call(datum)
        end
      end

      def response_call(datum)
        if datum.has_key?(:instrumentor)
          datum[:instrumentor].instrument("#{datum[:instrumentor_name]}.response", datum[:response]) do
            @stack.response_call(datum)
          end
        else
          @stack.response_call(datum)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
excon-0.51.0 lib/excon/middlewares/instrumentor.rb
excon-0.50.1 lib/excon/middlewares/instrumentor.rb
excon-0.50.0 lib/excon/middlewares/instrumentor.rb
excon-0.49.0 lib/excon/middlewares/instrumentor.rb
excon-0.48.0 lib/excon/middlewares/instrumentor.rb
excon-0.47.0 lib/excon/middlewares/instrumentor.rb