Sha256: e7dbdcf30140e0705d9690a114d7c75b7d4cd53bd6aebf21f5f75880416a897b

Contents?: true

Size: 1.16 KB

Versions: 136

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

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

136 entries across 136 versions & 1 rubygems

Version Path
appsignal-2.11.10-java lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.10 lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.9-java lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.9 lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.8-java lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.8 lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.7 lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.7-java lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.6 lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.6-java lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.5-java lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.5 lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.4-java lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.11.4 lib/appsignal/integrations/object_ruby_19.rb
appsignal-2.10.12 lib/appsignal/integrations/object.rb
appsignal-2.10.12-java lib/appsignal/integrations/object.rb
appsignal-2.10.11 lib/appsignal/integrations/object.rb
appsignal-2.10.11-java lib/appsignal/integrations/object.rb
appsignal-2.10.10 lib/appsignal/integrations/object.rb
appsignal-2.10.10-java lib/appsignal/integrations/object.rb