class ElasticAPM::Metrics::Registry

def start

def start
  unless config.collect_metrics?
    debug 'Skipping metrics'
    return
  end
  debug 'Starting metrics'
  # Only set the @sets once, in case we stop
  # and start again.
  @sets ||= {
    system: CpuMemSet,
    vm: VMSet,
    breakdown: BreakdownSet,
    transaction: TransactionSet
  }.each_with_object({}) do |(key, kls), sets|
    debug "Adding metrics collector '#{kls}'"
    sets[key] = kls.new(config)
  end
  @timer_task = Concurrent::TimerTask.execute(
    run_now: true,
    execution_interval: config.metrics_interval,
    timeout_interval: TIMEOUT_INTERVAL
  ) do
    begin
      debug 'Collecting metrics'
      collect_and_send
      true
    rescue StandardError => e
      error 'Error while collecting metrics: %e', e.inspect
      debug { e.backtrace.join("\n") }
      false
    end
  end
  @running = true
end