Sha256: 1e69a1fd266a9eef0cce673d47920e815ccaf1a743249435fd601ff1e2e6a752

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

module ElasticAPM
  module Metrics
    # @api private
    class SpanScopedSet < Set
      def collect
        super.tap do |sets|
          return 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

1 entries across 1 versions & 1 rubygems

Version Path
elastic-apm-3.2.0 lib/elastic_apm/metrics/span_scoped_set.rb