Sha256: bc1f457c2d5b718c8252de24a9cecd70e1fdf6fba9d0176ea2b4880f62c1a644

Contents?: true

Size: 1.26 KB

Versions: 32

Compression:

Stored size: 1.26 KB

Contents

# -*- ruby -*-
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/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, span_id = 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, span_id)
          end
          notify_if_full
        end
      end

      private

      def create_event(noticed_error, transaction_payload, span_id)
        TransactionErrorPrimitive.create(noticed_error, transaction_payload, span_id)
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
newrelic_rpm-9.16.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.6.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.5.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.4.2 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.4.1 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.4.0 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.3.1 lib/new_relic/agent/error_event_aggregator.rb
newrelic_rpm-9.3.0 lib/new_relic/agent/error_event_aggregator.rb