Sha256: e18f1d6da70a191107743f013e2348e24a4fcd6de2941390f899cd2eda145105

Contents?: true

Size: 884 Bytes

Versions: 4

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

module ElasticAPM
  module Metrics
    # @api private
    class SpanScopedSet < Set
      def collect
        super.tap do |sets|
          next unless sets

          sets.each do |set|
            move_transaction(set)
            move_span(set)
          end
        end
      end

      private

      def move_transaction(set)
        name = set.tags&.delete(:'transaction.name')
        type = set.tags&.delete(:'transaction.type')
        return unless name || type

        set.transaction = { name: name, type: type }
        set.tags = nil if set.tags.empty?
      end

      def move_span(set)
        type = set.tags&.delete(:'span.type')
        subtype = set.tags&.delete(:'span.subtype')
        return unless type

        set.span = { type: type, subtype: subtype }
        set.tags = nil if set.tags.empty?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
elastic-apm-3.6.0 lib/elastic_apm/metrics/span_scoped_set.rb
elastic-apm-3.5.0 lib/elastic_apm/metrics/span_scoped_set.rb
elastic-apm-3.4.0 lib/elastic_apm/metrics/span_scoped_set.rb
elastic-apm-3.3.0 lib/elastic_apm/metrics/span_scoped_set.rb