Module: Appom::Performance::MethodInstrumentation::ClassMethods
- Defined in:
- lib/appom/performance.rb
Overview
Class methods for method instrumentation
Instance Method Summary collapse
-
#instrument_method(method_name, operation_name: nil) ⇒ Object
Instrument methods for performance monitoring.
-
#instrument_methods(pattern, operation_prefix: nil) ⇒ Object
Instrument all methods matching pattern.
Instance Method Details
#instrument_method(method_name, operation_name: nil) ⇒ Object
Instrument methods for performance monitoring
334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/appom/performance.rb', line 334 def instrument_method(method_name, operation_name: nil) operation_name ||= "#{name}##{method_name}" alias_method "#{method_name}_without_instrumentation", method_name define_method(method_name) do |*args, &block| Appom::Performance.monitor.time_operation(operation_name) do send("#{method_name}_without_instrumentation", *args, &block) end end end |
#instrument_methods(pattern, operation_prefix: nil) ⇒ Object
Instrument all methods matching pattern
347 348 349 350 351 352 353 |
# File 'lib/appom/performance.rb', line 347 def instrument_methods(pattern, operation_prefix: nil) operation_prefix ||= name instance_methods(false).grep(pattern).each do |method_name| instrument_method(method_name, operation_name: "#{operation_prefix}##{method_name}") end end |