Sha256: cf29a2d433018c5cc723269d684877802cde7ae491c983a75b5c16c075220a4c

Contents?: true

Size: 851 Bytes

Versions: 37

Compression:

Stored size: 851 Bytes

Contents

# encoding: utf-8

require 'one_apm/support/event_buffer'
require 'one_apm/support/event_buffer/sized_buffer'

module OneApm
  module Agent
    class SyntheticsEventBuffer < SizedBuffer

      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 = "timestamp".freeze

      def timestamp_for(event)
        main_event, _ = event
        main_event[TIMESTAMP]
      end

    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
oneapm_rpm-1.3.6 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.6.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.5 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.5.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.4 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.4.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.3 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.3.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.2 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.2.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.1.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.0 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.3.0.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.2.9 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.2.9.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.2.8 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.2.8.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.2.7 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
oneapm_rpm-1.2.7.rc1 lib/one_apm/support/event_buffer/synthetics_event_buffer.rb