11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/zipkin-tracer/zipkin_http_sender.rb', line 11
def perform(json_api_host, spans)
spans_with_ips =
::ZipkinTracer::HostnameResolver.new.spans_with_ips(spans, ZipkinHttpSender::IP_FORMAT).map(&:to_h)
resp = Faraday.new(json_api_host).post do |req|
req.url SPANS_PATH
req.['Content-Type'] = 'application/json'
req.body = JSON.generate(spans_with_ips)
end
rescue Net::ReadTimeout, Faraday::ConnectionFailed => e
error_message = "Error while connecting to #{json_api_host}: #{e.class.inspect} with message '#{e.message}'. " \
"Please make sure the URL / port are properly specified for the Zipkin server."
SuckerPunch.logger.error(error_message)
rescue => e
SuckerPunch.logger.error(e)
end
|