Sha256: 9a83c3fb1e8aca5d70edbe1c5f2a791d9413a30b6ccf3e9094da1fc588327d20

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# -*- ruby -*-
# 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.
# frozen_string_literal: true

require 'new_relic/agent/event_aggregator'
require 'new_relic/agent/transaction_error_primitive'
require 'new_relic/agent/priority_sampled_buffer'

module NewRelic
  module Agent
    class ErrorEventAggregator < EventAggregator
      include NewRelic::Coerce

      named :ErrorEventAggregator
      capacity_key :'error_collector.max_event_samples_stored'
      enabled_keys :'error_collector.enabled',
                   :'error_collector.capture_events'
      buffer_class PrioritySampledBuffer

      def record noticed_error, transaction_payload = nil
        return unless enabled?

        priority = float!((transaction_payload && transaction_payload[:priority]) || rand)

        @lock.synchronize do
          @buffer.append(priority: priority) do
            create_event(noticed_error, transaction_payload)
          end
          notify_if_full
        end
      end

      private

      def create_event noticed_error, transaction_payload
        TransactionErrorPrimitive.create noticed_error, transaction_payload
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
newrelic_rpm-6.9.0.363 lib/new_relic/agent/error_event_aggregator.rb