Module: RubyMethodTracer::ClassMethods

Defined in:
lib/ruby_method_tracer.rb

Overview

Class-level API mixed into including classes.

Provides ‘trace_methods`, which wraps the specified instance methods on the target class using `RubyMethodTracer::SimpleTracer`. Each wrapped method records execution metrics (duration, status, errors) with minimal intrusion.

Usage:

class MyService
  include RubyMethodTracer
  def call; expensive_work; end
end
MyService.trace_methods(:call, threshold: 0.005, auto_output: true)

Instance Method Summary collapse

Instance Method Details

#trace_methods(*method_names, **options) ⇒ Object



46
47
48
49
50
51
# File 'lib/ruby_method_tracer.rb', line 46

def trace_methods(*method_names, **options)
  tracer = SimpleTracer.new(self, **options)
  method_names.each do |method_name|
    tracer.trace_method(method_name)
  end
end