module ElasticAPM::SpanHelpers::ClassMethods

def __span_method_on(klass, method, name = nil, type = nil)

def __span_method_on(klass, method, name = nil, type = nil)
  name ||= method.to_s
  type ||= Span::DEFAULT_TYPE
  klass.prepend(Module.new do
    define_method(method) do |*args|
      unless ElasticAPM.current_transaction
        return super(*args)
      end
      ElasticAPM.with_span name.to_s, type.to_s do
        super(*args)
      end
    end
  end)
end

def span_class_method(method, name = nil, type = nil)

def span_class_method(method, name = nil, type = nil)
  __span_method_on(singleton_class, method, name, type)
end

def span_method(method, name = nil, type = nil)

def span_method(method, name = nil, type = nil)
  __span_method_on(self, method, name, type)
end