Sha256: 54b24cd991ee1dc6c92cd22c5b1cb36bd37564ad1408be4b01c8c316f2ad8b43

Contents?: true

Size: 1.13 KB

Versions: 58

Compression:

Stored size: 1.13 KB

Contents

class Object
  def self.appsignal_instrument_class_method(method_name, options = {})
    singleton_class.send \
      :alias_method, "appsignal_uninstrumented_#{method_name}", method_name
    singleton_class.send(:define_method, method_name) do |*args, &block|
      name = options.fetch(:name) do
        "#{method_name}.class_method.#{appsignal_reverse_class_name}.other"
      end
      Appsignal.instrument name do
        send "appsignal_uninstrumented_#{method_name}", *args, &block
      end
    end
  end

  def self.appsignal_instrument_method(method_name, options = {})
    alias_method "appsignal_uninstrumented_#{method_name}", method_name
    define_method method_name do |*args, &block|
      name = options.fetch(:name) do
        "#{method_name}.#{appsignal_reverse_class_name}.other"
      end
      Appsignal.instrument name do
        send "appsignal_uninstrumented_#{method_name}", *args, &block
      end
    end
  end

  def self.appsignal_reverse_class_name
    return "AnonymousClass" unless name
    name.split("::").reverse.join(".")
  end

  def appsignal_reverse_class_name
    self.class.appsignal_reverse_class_name
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
appsignal-2.5.3-java lib/appsignal/integrations/object.rb
appsignal-2.5.3 lib/appsignal/integrations/object.rb
appsignal-2.5.3.alpha.2 lib/appsignal/integrations/object.rb
appsignal-2.5.3.alpha.2-java lib/appsignal/integrations/object.rb
appsignal-2.5.3.alpha.1 lib/appsignal/integrations/object.rb
appsignal-2.5.3.alpha.1-java lib/appsignal/integrations/object.rb
appsignal-2.5.2-java lib/appsignal/integrations/object.rb
appsignal-2.5.2 lib/appsignal/integrations/object.rb
appsignal-2.5.1-java lib/appsignal/integrations/object.rb
appsignal-2.5.1 lib/appsignal/integrations/object.rb
appsignal-2.5.1.beta.1-java lib/appsignal/integrations/object.rb
appsignal-2.5.1.beta.1 lib/appsignal/integrations/object.rb
appsignal-2.5.0-java lib/appsignal/integrations/object.rb
appsignal-2.5.0 lib/appsignal/integrations/object.rb
appsignal-2.5.0.beta.1-java lib/appsignal/integrations/object.rb
appsignal-2.5.0.beta.1 lib/appsignal/integrations/object.rb
appsignal-2.5.0.alpha.1-java lib/appsignal/integrations/object.rb
appsignal-2.5.0.alpha.1 lib/appsignal/integrations/object.rb
appsignal-2.4.3 lib/appsignal/integrations/object.rb
appsignal-2.4.2 lib/appsignal/integrations/object.rb