8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/oboe/inst/faraday.rb', line 8
def run_request_with_oboe(method, url, body, , &block)
handle_service = !@builder.handlers.include?(Faraday::Adapter::NetHttp)
Oboe::API.log_entry('faraday')
result = run_request_without_oboe(method, url, body, , &block)
kvs = {}
kvs[:HTTPStatus] = result.status
kvs['Middleware'] = @builder.handlers
kvs['Backtrace'] = Oboe::API.backtrace if Oboe::Config[:faraday][:collect_backtraces]
if handle_service
blacklisted = Oboe::API.blacklisted?(@url_prefix.to_s)
context = Oboe::Context.toString
task_id = Oboe::XTrace.task_id(context)
@headers['X-Trace'] = context unless blacklisted
kvs['IsService'] = 1
kvs['RemoteProtocol'] = (@url_prefix.scheme == 'https') ? 'HTTPS' : 'HTTP'
kvs['RemoteHost'] = @url_prefix.host
kvs['RemotePort'] = @url_prefix.port
kvs['ServiceArg'] = url
kvs['HTTPMethod'] = method
kvs['Blacklisted'] = true if blacklisted
unless blacklisted
xtrace = result.['X-Trace']
if Oboe::XTrace.valid?(xtrace) && Oboe.tracing?
if task_id == Oboe::XTrace.task_id(xtrace)
Oboe::Context.fromString(xtrace)
else
Oboe.logger.debug "Mismatched returned X-Trace ID: #{xtrace}"
end
end
end
end
Oboe::API.log('faraday', 'info', kvs)
result
rescue => e
Oboe::API.log_exception('faraday', e)
raise e
ensure
Oboe::API.log_exit('faraday')
end
|