Module: Sequel::Plugins::OneapmInstrumentation::MethodTracer
- Included in:
- ClassMethods, InstanceMethods
- Defined in:
- lib/sequel/plugins/oneapm_instrumentation.rb
Instance Method Summary collapse
- #add_method_tracer(method_name, metric = nil, options = {}) ⇒ Object
- #make_tracer_method(opname, options) ⇒ Object
Instance Method Details
#add_method_tracer(method_name, metric = nil, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sequel/plugins/oneapm_instrumentation.rb', line 24 def add_method_tracer( method_name, metric=nil, ={} ) # Shift options hash if metric is omitted if metric.is_a?( Hash ) = metric metric = nil end metric ||= method_name.to_s body = make_tracer_method( metric, ) define_method( method_name, &body ) end |
#make_tracer_method(opname, options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sequel/plugins/oneapm_instrumentation.rb', line 12 def make_tracer_method( opname, ) body = Proc.new do |*args, &block| classname = self.is_a?( Class ) ? self.name : self.class.name metric = "Database/%s/%s" % [ classname, opname ] trace_execution_scoped( metric, ) do super( *args, &block ) end end return body end |