Class: AsyncJsonApiClient

Inherits:
Object
  • Object
show all
Includes:
SuckerPunch::Job
Defined in:
lib/zipkin-tracer/zipkin_json_tracer.rb

Constant Summary collapse

SPANS_PATH =
'/api/v1/spans'

Instance Method Summary collapse

Instance Method Details

#perform(json_api_host, spans) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/zipkin-tracer/zipkin_json_tracer.rb', line 10

def perform(json_api_host, spans)
  spans_with_ips = ::ZipkinTracer::HostnameResolver.new.spans_with_ips(spans).map(&:to_h)
  resp = Faraday.new(json_api_host).post do |req|
    req.url SPANS_PATH
    req.headers['Content-Type'] = 'application/json'
    req.body = JSON.generate(spans_with_ips)
  end
rescue => e
  SuckerPunch.logger.error(e)
end