Class: NewRelic::Agent::TransactionEventRecorder
- Inherits:
-
Object
- Object
- NewRelic::Agent::TransactionEventRecorder
- 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
-
#synthetics_event_aggregator ⇒ Object
readonly
Returns the value of attribute synthetics_event_aggregator.
-
#transaction_event_aggregator ⇒ Object
readonly
Returns the value of attribute transaction_event_aggregator.
Instance Method Summary collapse
- #create_event(payload) ⇒ Object
- #drop_buffered_data ⇒ Object
-
#initialize(events) ⇒ TransactionEventRecorder
constructor
A new instance of TransactionEventRecorder.
- #record(payload) ⇒ Object
- #synthetics_event?(payload) ⇒ Boolean
Constructor Details
#initialize(events) ⇒ TransactionEventRecorder
Returns a new instance of TransactionEventRecorder.
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_aggregator ⇒ Object (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_aggregator ⇒ Object (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
35 36 37 |
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 35 def create_event(payload) TransactionEventPrimitive.create(payload) end |
#drop_buffered_data ⇒ Object
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
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
39 40 41 |
# File 'lib/new_relic/agent/transaction_event_recorder.rb', line 39 def synthetics_event?(payload) payload.key?(:synthetics_resource_id) end |