Sha256: ee9179865c6f08eb2af44e7ef035f7bc83659ce8bd7db884404d8bf9d5ee4833

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/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_keys :'span_events.enabled',
                   :'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

8 entries across 8 versions & 1 rubygems

Version Path
newrelic_rpm-7.2.0 lib/new_relic/agent/span_event_aggregator.rb
newrelic_rpm-7.1.0 lib/new_relic/agent/span_event_aggregator.rb
newrelic_rpm-7.0.0 lib/new_relic/agent/span_event_aggregator.rb
newrelic_rpm-6.15.0 lib/new_relic/agent/span_event_aggregator.rb
newrelic_rpm-6.14.0 lib/new_relic/agent/span_event_aggregator.rb
newrelic_rpm-6.13.1 lib/new_relic/agent/span_event_aggregator.rb
newrelic_rpm-6.13.0 lib/new_relic/agent/span_event_aggregator.rb
newrelic_rpm-6.12.0.367 lib/new_relic/agent/span_event_aggregator.rb