class Honeybadger::Breadcrumbs::Collector

Public Class Methods

new(config, buffer = RingBuffer.new) click to toggle source
# File lib/honeybadger/breadcrumbs/collector.rb, line 29
def initialize(config, buffer = RingBuffer.new)
  @config = config
  @buffer = buffer
end

Public Instance Methods

<<(breadcrumb)
Alias for: add!
add!(breadcrumb) click to toggle source

Add Breadcrumb to stack

@return [self] Filtered breadcrumbs

# File lib/honeybadger/breadcrumbs/collector.rb, line 37
def add!(breadcrumb)
  return unless @config[:'breadcrumbs.enabled']
  @buffer.add!(breadcrumb)

  self
end
Also aliased as: <<
drop_previous_breadcrumb_if() { |previous| ... } click to toggle source

@api private Removes the prevous breadcrumb from the buffer if the supplied block returns a falsy value

# File lib/honeybadger/breadcrumbs/collector.rb, line 50
def drop_previous_breadcrumb_if
  @buffer.drop if (previous && block_given? && yield(previous))
end
to_h() click to toggle source
# File lib/honeybadger/breadcrumbs/collector.rb, line 62
def to_h
  {
    enabled: @config[:'breadcrumbs.enabled'],
    trail: trail.map(&:to_h)
  }
end
trail() click to toggle source

All active breadcrumbs you want to remove a breadcrumb from the trail, then you can selectively ignore breadcrumbs while building a notice.

@return [Array] Active breadcrumbs

# File lib/honeybadger/breadcrumbs/collector.rb, line 58
def trail
  select(&:active?)
end

Private Instance Methods

initialize_dup(source) click to toggle source

@api private Since the collector is shared with the worker thread, there is a chance it can be cleared before we have prepared the request. We provide the ability to duplicate a collector which should also duplicate the buffer instance, as that holds the breadcrumbs.

Calls superclass method
# File lib/honeybadger/breadcrumbs/collector.rb, line 76
def initialize_dup(source)
  @buffer = source.instance_variable_get(:@buffer).dup
  super
end