Class: Object

Inherits:
BasicObject
Defined in:
lib/appsignal/integrations/object.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.appsignal_instrument_class_method(method_name, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/appsignal/integrations/object.rb', line 4

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

.appsignal_instrument_method(method_name, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/appsignal/integrations/object.rb', line 17

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

.appsignal_reverse_class_nameObject



29
30
31
32
# File 'lib/appsignal/integrations/object.rb', line 29

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

Instance Method Details

#appsignal_reverse_class_nameObject



34
35
36
# File 'lib/appsignal/integrations/object.rb', line 34

def appsignal_reverse_class_name
  self.class.appsignal_reverse_class_name
end