lib/elastic_apm/span_helpers.rb in elastic-apm-3.15.1 vs lib/elastic_apm/span_helpers.rb in elastic-apm-4.0.0.beta.1

- old
+ new

@@ -34,22 +34,20 @@ def __span_method_on(klass, method, name = nil, type = nil) name ||= method.to_s type ||= Span::DEFAULT_TYPE - klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 - alias :"__without_apm_#{method}" :"#{method}" - - def #{method}(*args, &block) + klass.prepend(Module.new do + define_method(method) do |*args| unless ElasticAPM.current_transaction - return __without_apm_#{method}(*args, &block) + return super(*args) end - ElasticAPM.with_span "#{name}", "#{type}" do - __without_apm_#{method}(*args, &block) + ElasticAPM.with_span name.to_s, type.to_s do + super(*args) end end - RUBY + end) end end def self.included(kls) kls.class_eval do