Module: Sequel::Plugins::NewRelicInstrumentation::MethodWrapping
- Included in:
- ClassMethods, InstanceMethods
- Defined in:
- lib/sequel/plugins/new_relic_instrumentation.rb
Overview
Meta-programming for creating method tracers for the Sequel::Model plugin.
Instance Method Summary collapse
-
#wrap_sequel_method(method_name, operation_name = method_name) ⇒ Object
Install a method named
method_name
that will trace execution with a metric name derived fromoperation_name
(ormethod_name
ifoperation_name
isn’t specified).
Instance Method Details
#wrap_sequel_method(method_name, operation_name = method_name) ⇒ Object
Install a method named method_name
that will trace execution with a metric name derived from operation_name
(or method_name
if operation_name
isn’t specified).
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sequel/plugins/new_relic_instrumentation.rb', line 20 def wrap_sequel_method(method_name, operation_name = method_name) define_method(method_name) do |*args, &block| klass = self.is_a?(Class) ? self : self.class product = NewRelic::Agent::Instrumentation::SequelHelper.product_name_from_adapter(db.adapter_scheme) segment = NewRelic::Agent::Tracer.start_datastore_segment( product: product, operation: operation_name, collection: klass.name ) begin NewRelic::Agent.disable_all_tracing { super(*args, &block) } ensure ::NewRelic::Agent::Transaction::Segment.finish(segment) end end end |