Class: Excon::Middleware::Instrumentor

Inherits:
Base
  • Object
show all
Defined in:
lib/excon/middlewares/instrumentor.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Excon::Middleware::Base

Instance Method Details

#error_call(datum) ⇒ Object



4
5
6
7
8
9
# File 'lib/excon/middlewares/instrumentor.rb', line 4

def error_call(datum)
  if datum.has_key?(:instrumentor)
    datum[:instrumentor].instrument("#{datum[:instrumentor_name]}.error", :error => datum[:error])
  end
  @stack.error_call(datum)
end

#request_call(datum) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/excon/middlewares/instrumentor.rb', line 11

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

#response_call(datum) ⇒ Object



26
27
28
29
30
31
# File 'lib/excon/middlewares/instrumentor.rb', line 26

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