Module: OneApm::Agent::Datastore
- Defined in:
- lib/one_apm/agent/datastore.rb,
lib/one_apm/agent/datastore/mongo.rb,
lib/one_apm/agent/datastore/metric_helper.rb,
lib/one_apm/agent/datastore/mongo/obfuscator.rb,
lib/one_apm/agent/datastore/mongo/command_formatter.rb,
lib/one_apm/agent/datastore/mongo/metric_translator.rb,
lib/one_apm/agent/datastore/mongo/statement_formatter.rb
Defined Under Namespace
Modules: MetricHelper, Mongo
Class Method Summary collapse
- .notice_sql(query, scoped_metric, elapsed) ⇒ Object
- .notice_statement(statement, elapsed) ⇒ Object
- .trace(clazz, method_name, product, operation = method_name) ⇒ Object
- .wrap(product, operation, collection = nil, callback = nil) ⇒ Object
Class Method Details
.notice_sql(query, scoped_metric, elapsed) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/one_apm/agent/datastore.rb', line 51 def self.notice_sql(query, scoped_metric, elapsed) agent = OneApm::Manager.agent agent.transaction_sampler.notice_sql(query, nil, elapsed) agent.sql_sampler.notice_sql(query, scoped_metric, nil, elapsed) nil end |
.notice_statement(statement, elapsed) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/one_apm/agent/datastore.rb', line 58 def self.notice_statement(statement, elapsed) return unless OneApm::Agent::Database.should_record_sql? agent = OneApm::Manager.agent agent.transaction_sampler.notice_nosql_statement(statement, elapsed) nil end |
.trace(clazz, method_name, product, operation = method_name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/one_apm/agent/datastore.rb', line 9 def self.trace(clazz, method_name, product, operation = method_name) clazz.class_eval do method_name_without_oneapm = "#{method_name}_without_oneapm" if OneApm::Helper.instance_methods_include?(clazz, method_name) && !OneApm::Helper.instance_methods_include?(clazz, method_name_without_oneapm) visibility = OneApm::Helper.instance_method_visibility(clazz, method_name) alias_method method_name_without_oneapm, method_name define_method(method_name) do |*args, &blk| metrics = MetricHelper.metrics_for(product, operation) OneApm::Support::MethodTracer.trace_execution_scoped(metrics) do send(method_name_without_oneapm, *args, &blk) end end send visibility, method_name send visibility, method_name_without_oneapm end end end |
.wrap(product, operation, collection = nil, callback = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/one_apm/agent/datastore.rb', line 33 def self.wrap(product, operation, collection = nil, callback = nil) return yield unless operation metrics = MetricHelper.metrics_for(product, operation, collection) scoped_metric = metrics.first OneApm::Support::MethodTracer.trace_execution_scoped(metrics) do t0 = Time.now begin result = yield ensure if callback elapsed_time = (Time.now - t0).to_f callback.call(result, scoped_metric, elapsed_time) end end end end |