24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/metrixwire/instrument/net_http.rb', line 24
def request(req, body = nil, &block)
return super if Context.current.nil?
desc = MetrixWire::Instrument::NetHttp.describe(self, req)
if desc.nil? || MetrixWire::Instrument::NetHttp.own_endpoint?(desc)
return super
end
t0 = MetrixWire.monotonic_ms
resp = super
status = begin
resp.respond_to?(:code) ? resp.code.to_i : nil
rescue StandardError
nil
end
Helpers.add_span("http_call", desc, MetrixWire.monotonic_ms - t0,
meta: (status ? { statusCode: status } : nil))
resp
rescue StandardError => e
raise e
end
|