Class: Faraday::Aws::XRay::Middleware

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/aws/xray/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



7
8
9
10
# File 'lib/faraday/aws/xray/middleware.rb', line 7

def initialize(app, options = {})
  super(app)
  @name = options[:name] || 'external_http_request'
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/faraday/aws/xray/middleware.rb', line 12

def call(env)
  ::XRay.recorder.capture(@name) do |_segment|
    ::XRay.recorder.capture(env.url.to_s) do |subsegment|
      add_request_data(subsegment, env)

      response = @app.call(env)

      add_response_data(subsegment, response)
      response
    end
  end
end