Sha256: 049ddc7be5d4b7b6a50de085ac50b94368b459a9b76012bd664f82f37b582706

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true
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

15 entries across 13 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/excon-0.62.0/lib/excon/middlewares/instrumentor.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/excon-0.62.0/lib/excon/middlewares/instrumentor.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/excon-0.62.0/lib/excon/middlewares/instrumentor.rb
excon-0.62.0 lib/excon/middlewares/instrumentor.rb
excon-0.61.0 lib/excon/middlewares/instrumentor.rb
excon-0.60.0 lib/excon/middlewares/instrumentor.rb
excon-0.59.0 lib/excon/middlewares/instrumentor.rb
excon-0.58.0 lib/excon/middlewares/instrumentor.rb
excon-0.57.1 lib/excon/middlewares/instrumentor.rb
excon-0.57.0 lib/excon/middlewares/instrumentor.rb
excon-0.56.0 lib/excon/middlewares/instrumentor.rb
excon-0.55.0 lib/excon/middlewares/instrumentor.rb
excon-0.54.0 lib/excon/middlewares/instrumentor.rb
excon-0.53.0 lib/excon/middlewares/instrumentor.rb
excon-0.52.0 lib/excon/middlewares/instrumentor.rb