Class: NewRelic::Agent::TransactionEventRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/transaction_event_recorder.rb

Overview

This is responsible for recording transaction events and managing the relationship between events generated from synthetics requests vs normal requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ TransactionEventRecorder

Returns a new instance of TransactionEventRecorder.

[View source]

18
19
20
21
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 18

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

Instance Attribute Details

#synthetics_event_aggregatorObject (readonly)

Returns the value of attribute synthetics_event_aggregator.


16
17
18
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 16

def synthetics_event_aggregator
  @synthetics_event_aggregator
end

#transaction_event_aggregatorObject (readonly)

Returns the value of attribute transaction_event_aggregator.


15
16
17
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 15

def transaction_event_aggregator
  @transaction_event_aggregator
end

Instance Method Details

#create_event(payload) ⇒ Object

[View source]

35
36
37
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 35

def create_event(payload)
  TransactionEventPrimitive.create(payload)
end

#drop_buffered_dataObject

[View source]

43
44
45
46
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 43

def drop_buffered_data
  transaction_event_aggregator.reset!
  synthetics_event_aggregator.reset!
end

#record(payload) ⇒ Object

[View source]

23
24
25
26
27
28
29
30
31
32
33
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 23

def record(payload)
  return unless NewRelic::Agent.config[:'transaction_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

#synthetics_event?(payload) ⇒ Boolean

Returns:

  • (Boolean)
[View source]

39
40
41
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 39

def synthetics_event?(payload)
  payload.key?(:synthetics_resource_id)
end