in lib/aws-xray-sdk/facets/net_http.rb [39:78]
def request(req, body = nil, &block)
if xray_sampling_request?(req) || lambda_runtime_request? || ec2_metadata_request?(req)
return super
end
entity = XRay.recorder.current_entity
capture = !(entity && entity.namespace && entity.namespace == 'aws'.freeze)
if started? && capture && entity
XRay.recorder.capture(address, namespace: 'remote') do |subsegment|
protocol = use_ssl? ? 'https'.freeze : 'http'.freeze
iport = port.nil? ? nil : %(:
path = req.path.split('?')[0] if req.path
uri = %(
req_meta = {
url: uri,
method: req.method
}
subsegment.merge_http_request request: req_meta
req[TRACE_HEADER] = prep_header_str entity: subsegment
begin
res = super
res_meta = {
status: res.code.to_i,
content_length: res.content_length
}
subsegment.merge_http_response response: res_meta
res
rescue Exception => e
subsegment.add_exception exception: e
raise e
end
end
else
super
end
end