Sha256: 887d25a2bd66c5449d1ccc57b4e79426299fdc5884ada71e905842ed9f3add46

Contents?: true

Size: 874 Bytes

Versions: 15

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module ElasticAPM
  # @api private
  module SpanHelpers
    # @api private
    module ClassMethods
      def span_class_method(method, name, type)
        __span_method_on(singleton_class, method, name, type)
      end

      private

      def __span_method_on(klass, method, name, type)
        klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
          alias :"__without_apm_#{method}" :"#{method}"

          def #{method}(*args, &block)
            unless ElasticAPM.current_transaction
              return __without_apm_#{method}(*args, &block)
            end

            ElasticAPM.span "#{name}", "#{type}" do
              __without_apm_#{method}(*args, &block)
            end
          end
        RUBY
      end
    end

    def self.included(kls)
      kls.class_eval do
        extend ClassMethods
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
elastic-apm-0.7.1 lib/elastic_apm/span_helpers.rb
elastic-apm-0.7.0 lib/elastic_apm/span_helpers.rb
elastic-apm-0.6.2 lib/elastic_apm/span_helpers.rb
elastic-apm-0.6.1 lib/elastic_apm/span_helpers.rb
elastic-apm-0.5.1 lib/elastic_apm/span_helpers.rb
elastic-apm-0.5.0 lib/elastic_apm/span_helpers.rb
elastic-apm-0.4.5 lib/elastic_apm/span_helpers.rb
elastic-apm-0.4.4 lib/elastic_apm/span_helpers.rb
elastic-apm-0.4.3 lib/elastic_apm/span_helpers.rb
elastic-apm-0.4.2 lib/elastic_apm/span_helpers.rb
elastic-apm-0.4.1 lib/elastic_apm/span_helpers.rb
elastic-apm-0.4.0 lib/elastic_apm/span_helpers.rb
elastic-apm-0.3.0 lib/elastic_apm/span_helpers.rb
elastic-apm-0.2.0 lib/elastic_apm/span_helpers.rb
elastic-apm-0.1.0 lib/elastic_apm/span_helpers.rb