Sha256: cb79e2b6b9be8ab8de0268bc5e02fcf47d499897d45122a01a08324d7760da23
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
# encoding: utf-8 # This file is distributed under New Relic's license terms. # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details. require 'new_relic/agent/instrumentation/active_record_helper' class ActiveRecordTest < Performance::TestCase ActiveRecordHelper = NewRelic::Agent::Instrumentation::ActiveRecordHelper unless defined?(ActiveRecordHelper) def setup if ActiveRecordHelper.respond_to?(:metrics_for) @run = ActiveRecordHelper.method(:metrics_for) else # Mimics what was buried in the instrumentation that we replaced with # calls to metrics_for in the new instrumentation. Can run against SHA # 399d8ed for baselining (3.10 tags won't work since the perf testing # changed on dev post 3.10) @run = proc do |name, sql, adapter, *_| metric = ActiveRecordHelper.metric_for_name(name) || ActiveRecordHelper.metric_for_sql(sql) remote_service_metric = ActiveRecordHelper.remote_service_metric("host", adapter) metrics = [metric, remote_service_metric].compact metrics += ActiveRecordHelper.rollup_metrics_for(metric) end end end NAME = "Model Load" SQL = "SELECT * FROM star" ADAPTER = "mysql2" def test_helper_by_name measure do @run.call(NAME, SQL, ADAPTER) end end UNKNOWN_NAME = "Blah" def test_helper_by_sql measure do @run.call(UNKNOWN_NAME, SQL, ADAPTER) end end end
Version data entries
3 entries across 3 versions & 1 rubygems