class ChefApply::Telemeter

Public Class Methods

capture(name, data = {}, options = {}) click to toggle source
# File lib/chef_apply/telemeter.rb, line 40
def self.capture(name, data = {}, options = {})
  Chef::Telemeter.capture(name, data, options)
end
timed_action_capture(action, &block) click to toggle source
# File lib/chef_apply/telemeter.rb, line 24
def self.timed_action_capture(action, &block)
  # Note: we do not directly capture hostname for privacy concerns, but
  # using a sha1 digest will allow us to anonymously see
  # unique hosts to derive number of hosts affected by a command
  target = action.target_host
  target_data = { platform: {}, hostname_sha1: nil, transport_type: nil }
  if target
    target_data[:platform][:name] = target.base_os # :windows, :linux, eventually :macos
    target_data[:platform][:version] = target.version
    target_data[:platform][:architecture] = target.architecture
    target_data[:hostname_sha1] = Digest::SHA1.hexdigest(target.hostname.downcase)
    target_data[:transport_type] = target.transport_type
  end
  Chef::Telemeter.timed_capture(:action, { action: action.name, target: target_data }, &block)
end