diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-10 16:15:46 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-17 17:25:48 +0100 |
commit | 5dbcb635a17aff6543150a66b597c75b819801e2 (patch) | |
tree | d01bb21213882628b2ee2a6146d6d68e9d72dc4c /lib/gitlab | |
parent | ad69ba57d6e7d52b2a44a20393c072538c299653 (diff) | |
download | gitlab-ce-5dbcb635a17aff6543150a66b597c75b819801e2.tar.gz |
Methods for instrumenting multiple methods
The methods Instrumentation.instrument_methods and
Instrumentation.instrument_instance_methods can be used to instrument
all methods of a module at once.
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/metrics/instrumentation.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitlab/metrics/instrumentation.rb b/lib/gitlab/metrics/instrumentation.rb index 2ed75495650..12d5ede4be3 100644 --- a/lib/gitlab/metrics/instrumentation.rb +++ b/lib/gitlab/metrics/instrumentation.rb @@ -27,6 +27,29 @@ module Gitlab instrument(:instance, mod, name) end + # Instruments all public methods of a module. + # + # mod - The module to instrument. + def self.instrument_methods(mod) + mod.public_methods(false).each do |name| + instrument_method(mod, name) + end + end + + # Instruments all public instance methods of a module. + # + # mod - The module to instrument. + def self.instrument_instance_methods(mod) + mod.public_instance_methods(false).each do |name| + instrument_instance_method(mod, name) + end + end + + # Instruments a method. + # + # type - The type (:class or :instance) of method to instrument. + # mod - The module containing the method. + # name - The name of the method to instrument. def self.instrument(type, mod, name) return unless Metrics.enabled? |