class Mmtrix::Agent::SyntheticsEventBuffer

Constants

TIMESTAMP

Public Instance Methods

append_with_reject(x) click to toggle source
# File lib/mmtrix/agent/synthetics_event_buffer.rb, line 12
def append_with_reject(x)
  @seen += 1
  if full?
    timestamp = timestamp_for(x)
    latest_event = @items.max_by do |item|
      timestamp_for(item)
    end

    if timestamp < timestamp_for(latest_event)
      # Make room!
      @items.delete(latest_event)
      return [append_event(x), latest_event]
    else
      return [nil, x]
    end
  else
    return [append_event(x), nil]
  end
end
timestamp_for(event) click to toggle source
# File lib/mmtrix/agent/synthetics_event_buffer.rb, line 34
def timestamp_for(event)
  main_event, _ = event
  main_event[TIMESTAMP]
end