class Buildkite::Trace::Client

Public Class Methods

new(hostname) click to toggle source
# File lib/buildkite/trace/client.rb, line 6
def initialize(hostname)
  @uri = URI("http://#{hostname}:8126/v0.3/traces")
end

Public Instance Methods

submit_trace(array_of_spans) click to toggle source
# File lib/buildkite/trace/client.rb, line 10
def submit_trace(array_of_spans)
  array_of_traces = [array_of_spans]
  http = Net::HTTP.new(@uri.host, 8126)
  response = http.start do |http|
    request = Net::HTTP::Put.new(@uri.request_uri, { 'Content-Type' => 'application/json'})
    request.body = JSON.dump(array_of_traces)
    http.request(request)
  end
  response.code.to_i == 200
end