original_method = :"_untraced_method_#{method}" return if method_defined?(original_method) alias_method original_method, method define_method method do |*args, &block| ActiveSupport::Notifications.instrument("performance.#{name}") do send(original_method, *args, &block) end end end end