class Chef::Telemetry::Client

Constants

TELEMETRY_ENDPOINT

Attributes

http[R]

Public Class Methods

new(endpoint = TELEMETRY_ENDPOINT) click to toggle source
Calls superclass method
# File lib/chef/telemetry/client.rb, line 14
def initialize(endpoint = TELEMETRY_ENDPOINT)
  super()
  uri = URI(endpoint)
  @http = Net::HTTP.new(uri.host, uri.port)
  @http.use_ssl = uri.scheme == "https"
  @http.start
end

Public Instance Methods

fire(event) click to toggle source
# File lib/chef/telemetry/client.rb, line 22
def fire(event)
  req = Net::HTTP::Post.new("/events")
  req["Content-Type"] = "application/json"
  req.body = JSON.dump(event)
  # TODO: @cwolfe use response and at least debug log status
  http.request req
end