Sha256: 27f8c067f14917d0bd01154cef7664521936c162b2e280c89d37dfe5855b3005

Contents?: true

Size: 1.6 KB

Versions: 12

Compression:

Stored size: 1.6 KB

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/transaction_event_aggregator'
require 'new_relic/agent/synthetics_event_aggregator'
require 'new_relic/agent/transaction_event_primitive'

module NewRelic
  module Agent
    # This is responsibile for recording transaction events and managing
    # the relationship between events generated from synthetics requests
    # vs normal requests.
    class TransactionEventRecorder
      attr_reader :transaction_event_aggregator
      attr_reader :synthetics_event_aggregator

      def initialize
        @transaction_event_aggregator = NewRelic::Agent::TransactionEventAggregator.new
        @synthetics_event_aggregator = NewRelic::Agent::SyntheticsEventAggregator.new
      end

      def record payload
        return unless NewRelic::Agent.config[:'analytics_events.enabled']

        if synthetics_event? payload
          event = create_event payload
          result = synthetics_event_aggregator.record event
          transaction_event_aggregator.record event: event if result.nil?
        else
          transaction_event_aggregator.record(priority: payload[:priority]) { create_event(payload) }
        end
      end

      def create_event payload
        TransactionEventPrimitive.create payload
      end

      def synthetics_event? payload
        payload.key? :synthetics_resource_id
      end

      def drop_buffered_data
        transaction_event_aggregator.reset!
        synthetics_event_aggregator.reset!
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
newrelic_rpm-6.5.0.357 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-6.4.0.356 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-6.3.0.355 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-6.2.0.354 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-6.1.0.352 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-6.0.0.351 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-5.7.0.350 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-5.6.0.349 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-5.5.0.348 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-5.4.0.347 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/transaction_event_recorder.rb