Class: Honeybadger::RegistryExecution

Inherits:
Object
  • Object
show all
Defined in:
lib/honeybadger/registry_execution.rb

Instance Method Summary collapse

Constructor Details

#initialize(registry, config, options) ⇒ RegistryExecution

Returns a new instance of RegistryExecution.



3
4
5
6
7
8
9
# File 'lib/honeybadger/registry_execution.rb', line 3

def initialize(registry, config, options)
  @registry = registry
  @config = config
  @options = options
  @interval = config[:'insights.registry_flush_interval'] || options.fetch(:interval, 60)
  @end_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) + @interval
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
# File 'lib/honeybadger/registry_execution.rb', line 20

def call
  @registry.metrics.each do |metric|
    next if metric.samples == 0
    metric.event_payloads.each do |payload|
      Honeybadger.event(payload.merge(interval: @interval))
    end
  end
end

#resetObject



15
16
17
18
# File 'lib/honeybadger/registry_execution.rb', line 15

def reset
  @end_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) + @interval
  @registry.flush
end

#tickObject



11
12
13
# File 'lib/honeybadger/registry_execution.rb', line 11

def tick
  @end_time - ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
end