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
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sequel/plugins/oneapm_instrumentation.rb', line 25 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 23 |
# 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 op_name = OneApm::Agent::Instrumentation::ActiveRecordHelper.rename_for(opname) metrics = OneApm::Agent::Instrumentation::ActiveRecordHelper.metric_for(classname, op_name).compact trace_execution_scoped( metrics, ) do super( *args, &block ) end end return body end |