Sha256: e83b3bbc5d467429e89af2183dea202bad2cd37c9d9b3025632f9425708f1818

Contents?: true

Size: 1.57 KB

Versions: 21

Compression:

Stored size: 1.57 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
          _, rejected = synthetics_event_aggregator.append_or_reject event
          transaction_event_aggregator.append event if rejected
        else
          transaction_event_aggregator.append { 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

21 entries across 21 versions & 2 rubygems

Version Path
newrelic_rpm-4.5.0.337 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-4.4.0.336 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-4.3.0.335 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-4.2.0.334 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-4.1.0.333 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-4.0.0.332 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.18.1.330 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.18.0.329 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.17.2.327 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.17.1.326 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.17.0.325 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.16.3.323 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.16.2.321 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.16.1.320 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.16.0.318 lib/new_relic/agent/transaction_event_recorder.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.15.2.317 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.15.1.316 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.15.0.314 lib/new_relic/agent/transaction_event_recorder.rb
newrelic_rpm-3.14.3.313 lib/new_relic/agent/transaction_event_recorder.rb