Method: ElasticAPM::Metrics::Registry#start

Defined in:
lib/elastic_apm/metrics.rb

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/elastic_apm/metrics.rb', line 47

def start
  unless config.collect_metrics?
    debug 'Skipping metrics'
    return
  end

  define_sets

  debug 'Starting metrics'

  @timer_task = Concurrent::TimerTask.execute(
    run_now: true,
    execution_interval: config.metrics_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