lib/one_apm/inst/nosql/mongo2.rb in oneapm_rpm-1.3.7 vs lib/one_apm/inst/nosql/mongo2.rb in oneapm_rpm-1.4.0

- old
+ new

@@ -31,38 +31,41 @@ def operations @operations ||= {} end - def mertircs(event) - OneApm::Agent::Datastore::MetricHelper.metrics_for( - OA_MONGODB, event.command_name, event.command.values.first - ) + def generate_metrics(event) + @product ||= begin + host = event.address.host rescue nil + port = event.address.port rescue nil + OneApm::Agent::Datastore.oneapm_product(OA_MONGODB, host, port) + end + OneApm::Agent::Datastore::MetricHelper.metrics_for(@product, event.command_name, event.command.values.first) end def operator(operator_type, event) begin state = OneApm::TransactionState.tl_get return unless state.is_execution_traced? stared_event = operations.delete(event.operation_id) - one_apm_generate_metrics(stared_event, event.duration) + one_apm_record_metrics(stared_event, event.duration) one_apm_notice_statement(stared_event, operator_type, event.duration) one_apm_notice_sql(state, stared_event, operator_type, event.duration) rescue => e log_operations_error(operator_type, e) end end - def one_apm_generate_metrics(event, duration) - base, *other_metrics = mertircs(event) + def one_apm_record_metrics(event, duration) + base, *other_metrics = generate_metrics(event) OneApm::Manager.agent.stats_engine.tl_record_scoped_and_unscoped_metrics( base, other_metrics, duration ) end def one_apm_notice_sql(state, event, status, duration) stack = state.traced_method_stack - base, *other_metrics = mertircs(event) + base, *other_metrics = generate_metrics(event) started_time = Time.now.to_f frame = stack.push_frame(state, :mongo_tracer, started_time - duration) builder = state.transaction_sample_builder \ No newline at end of file