Sha256: 8f4da658230986128628b6b1ea59629191f3848e6fc9409c73c9d56b0c72b60f

Contents?: true

Size: 1.32 KB

Versions: 76

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true
module Excon
  module Middleware
    class Instrumentor < Excon::Middleware::Base
      def self.valid_parameter_keys
        [
          :logger,
          :instrumentor,
          :instrumentor_name
        ]
      end

      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

76 entries across 74 versions & 3 rubygems

Version Path
excon-1.2.2 lib/excon/middlewares/instrumentor.rb
excon-1.2.1 lib/excon/middlewares/instrumentor.rb
excon-1.2.0 lib/excon/middlewares/instrumentor.rb
excon-1.1.1 lib/excon/middlewares/instrumentor.rb
excon-1.1.0 lib/excon/middlewares/instrumentor.rb
excon-1.0.0 lib/excon/middlewares/instrumentor.rb
excon-0.112.0 lib/excon/middlewares/instrumentor.rb
excon-0.111.0 lib/excon/middlewares/instrumentor.rb
excon-0.110.0 lib/excon/middlewares/instrumentor.rb
excon-0.109.0 lib/excon/middlewares/instrumentor.rb
excon-0.108.0 lib/excon/middlewares/instrumentor.rb
excon-0.107.0 lib/excon/middlewares/instrumentor.rb
excon-0.106.0 lib/excon/middlewares/instrumentor.rb
excon-0.105.0 lib/excon/middlewares/instrumentor.rb
excon-0.104.0 lib/excon/middlewares/instrumentor.rb
excon-0.103.0 lib/excon/middlewares/instrumentor.rb
excon-0.102.0 lib/excon/middlewares/instrumentor.rb
excon-0.101.0 lib/excon/middlewares/instrumentor.rb
excon-0.100.0 lib/excon/middlewares/instrumentor.rb
excon-0.99.0 lib/excon/middlewares/instrumentor.rb