Sha256: ecee5f68232e4b0d3acd5c2266cdfbb44db0ae989429c07c7221364691cd8f80

Contents?: true

Size: 1.67 KB

Versions: 11

Compression:

Stored size: 1.67 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 'newrelic_rpm' unless defined?( NewRelic )
require 'new_relic/agent' unless defined?( NewRelic::Agent )
require 'new_relic/agent/event_aggregator'
require 'new_relic/agent/priority_sampled_buffer'

module NewRelic
  module Agent
    class SpanEventAggregator < EventAggregator
      named :SpanEventAggregator
      capacity_key :'span_events.max_samples_stored'

      enabled_fn -> {
        NewRelic::Agent.config[:'span_events.enabled'] &&
        NewRelic::Agent.config[:'distributed_tracing.enabled']
      }

      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

      SUPPORTABILITY_TOTAL_SEEN = "Supportability/SpanEvent/TotalEventsSeen".freeze
      SUPPORTABILITY_TOTAL_SENT = "Supportability/SpanEvent/TotalEventsSent".freeze
      SUPPORTABILITY_DISCARDED  = "Supportability/SpanEvent/Discarded".freeze

      def after_harvest metadata
        seen      = metadata[:seen]
        sent      = metadata[: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
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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