Class: NewRelic::Agent::SpanEventAggregator
- Inherits:
-
EventAggregator
- Object
- EventAggregator
- NewRelic::Agent::SpanEventAggregator
- Defined in:
- lib/new_relic/agent/span_event_aggregator.rb
Constant Summary collapse
- SUPPORTABILITY_TOTAL_SEEN =
'Supportability/SpanEvent/TotalEventsSeen'.freeze
- SUPPORTABILITY_TOTAL_SENT =
'Supportability/SpanEvent/TotalEventsSent'.freeze
- SUPPORTABILITY_DISCARDED =
'Supportability/SpanEvent/Discarded'.freeze
Instance Method Summary collapse
- #after_harvest(metadata) ⇒ Object
- #harvest! ⇒ Object
- #record(priority: nil, event: nil, &blk) ⇒ Object
Methods inherited from EventAggregator
#after_initialize, buffer_class, capacity_key, #enabled?, enabled_fn, enabled_keys, #has_metadata?, #initialize, #merge!, named, #reset!
Constructor Details
This class inherits a constructor from NewRelic::Agent::EventAggregator
Instance Method Details
#after_harvest(metadata) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/new_relic/agent/span_event_aggregator.rb', line 55 def after_harvest() seen = [:seen] sent = [:captured] discarded = seen - sent ::NewRelic::Agent.record_metric(SUPPORTABILITY_TOTAL_SEEN, count: seen) ::NewRelic::Agent.record_metric(SUPPORTABILITY_TOTAL_SENT, count: sent) ::NewRelic::Agent.record_metric(SUPPORTABILITY_DISCARDED, count: discarded) super end |
#harvest! ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/new_relic/agent/span_event_aggregator.rb', line 36 def harvest! , events = super # extra_events is for SpanLink and SpanEvent data related to a Span # SpanLink and SpanEvent events are both created by OpenTelemetry APIs extra_events = [] events.each do |event| # Spans are normally: [intrinsics, custom_attrs, agent_attrs]. # When a span has links, a 4th element is appended: # [intrinsics, custom_attrs, agent_attrs, extra_events] # # SpanLinks and SpanEvents must be sent to the backend at the top # level of the main payload, not nested inside an individual Span. # This pulls them out to be flattened into the final array: # [Span, SpanLink, Span, SpanEvent, Span] extra_events.concat(event.slice!(3)) if event.length > 3 end [, events.concat(extra_events)] end |
#record(priority: nil, event: nil, &blk) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/new_relic/agent/span_event_aggregator.rb', line 19 def record(priority: nil, event: nil, &blk) unless event || priority && blk raise ArgumentError, 'Expected priority and block, or event' end return unless enabled? @lock.synchronize do @buffer.append(priority: priority, event: event, &blk) notify_if_full end end |