Sha256: 9c9f781c39f415fe3764d53e7ff8a887c8b693008d5db53b8a4c65cce7725979

Contents?: true

Size: 940 Bytes

Versions: 27

Compression:

Stored size: 940 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'new_relic/agent/sized_buffer'

module NewRelic
  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

27 entries across 27 versions & 2 rubygems

Version Path
newrelic_rpm-5.1.0.344 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-5.0.0.342 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.8.0.341 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.7.1.340 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.7.0.339 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.6.0.338 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.5.0.337 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.4.0.336 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.3.0.335 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.2.0.334 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.1.0.333 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-4.0.0.332 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.18.1.330 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.18.0.329 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.17.2.327 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.17.1.326 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.17.0.325 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.16.3.323 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.16.2.321 lib/new_relic/agent/synthetics_event_buffer.rb
newrelic_rpm-3.16.1.320 lib/new_relic/agent/synthetics_event_buffer.rb