Skip to content
Browse files

RUBY-985 Rename StatsEngine#record_metric to record_metrics to match …

…its behavior
  • Loading branch information...
1 parent dcc46d6 commit d0ed5af1fa7350c1b9c6c943e24aa7163155eb2f @benweint benweint committed with jasonrclark Feb 20, 2013
View
4 lib/new_relic/agent.rb
@@ -186,7 +186,7 @@ def record_metric(metric_name, value)
stats.sum_of_squares = value[:sum_of_squares]
value = stats
end
- agent.stats_engine.record_metric(metric_name, value)
+ agent.stats_engine.record_metrics(metric_name, value)
end
# Increment a simple counter metric.
@@ -198,7 +198,7 @@ def record_metric(metric_name, value)
#
# @api public
def increment_metric(metric_name, amount=1)
- agent.stats_engine.record_metric(metric_name) do |stats|
+ agent.stats_engine.record_metrics(metric_name) do |stats|
stats.increment_count(amount)
end
end
View
2 lib/new_relic/agent/agent.rb
@@ -1032,7 +1032,7 @@ def transmit_data(disconnecting=false)
ensure
NewRelic::Agent::Database.close_connections unless forked?
duration = (Time.now - now).to_f
- @stats_engine.record_metric('Supportability/Harvest', duration)
+ @stats_engine.record_metrics('Supportability/Harvest', duration)
end
# This method contacts the server to send remaining data and
View
4 lib/new_relic/agent/cross_app_tracing.rb
@@ -70,8 +70,8 @@ def finish_trace( t0, segment, request, response, http )
# Report the metrics
duration = t1.to_f - t0.to_f
- stats_engine.record_metric(metrics, duration)
- stats_engine.record_metric(scoped_metric, duration, :scoped => true)
+ stats_engine.record_metrics(metrics, duration)
+ stats_engine.record_metrics(scoped_metric, duration, :scoped => true)
# Add TT custom parameters
stats_engine.rename_scope_segment( scoped_metric )
View
2 lib/new_relic/agent/error_collector.rb
@@ -107,7 +107,7 @@ def increment_error_count!(exception)
metric_names = ["Errors/all"]
metric_names << "Errors/#{txn_info.transaction_name}" if txn_info.transaction_name_set?
stats_engine = NewRelic::Agent.agent.stats_engine
- stats_engine.record_metric(metric_names) do |stats|
+ stats_engine.record_metrics(metric_names) do |stats|
stats.increment_count
end
end
View
4 lib/new_relic/agent/instrumentation/metric_frame.rb
@@ -304,10 +304,10 @@ def self.uri_from_request(request)
end
def self.record_apdex(current_metric, action_duration, total_duration, is_error)
- agent.stats_engine.record_metric('Apdex') do |stat|
+ agent.stats_engine.record_metrics('Apdex') do |stat|
update_apdex(stat, total_duration, is_error)
end
- agent.stats_engine.record_metric(current_metric.apdex_metric_path) do |stat|
+ agent.stats_engine.record_metrics(current_metric.apdex_metric_path) do |stat|
update_apdex(stat, action_duration, is_error)
end
end
View
2 lib/new_relic/agent/instrumentation/queue_time.rb
@@ -40,7 +40,7 @@ def parse_frontend_timestamp(headers, now=Time.now)
end
def record_frontend_metrics(start_time, now=Time.now)
- NewRelic::Agent.instance.stats_engine.record_metric(
+ NewRelic::Agent.instance.stats_engine.record_metrics(
ALL_QUEUE_METRIC, (now - start_time).to_f, :scoped => true)
end
View
6 lib/new_relic/agent/method_tracer.rb
@@ -80,9 +80,7 @@ def trace_execution_unscoped(metric_names, options={})
ensure
NewRelic::Agent.instance.pop_trace_execution_flag if options[:force]
duration = (Time.now - t0).to_f # for some reason this is 3 usec faster than Time - Time
- metric_names.each do |metric_name|
- NewRelic::Agent.record_metric(metric_name, duration)
- end
+ stat_engine.record_metrics(metric_names, duration)
end
end
@@ -209,7 +207,7 @@ def trace_execution_scoped_footer(t0, first_name, metric_specs, expected_scope,
if expected_scope
scope = stat_engine.pop_scope(expected_scope, duration, t1)
exclusive = duration - scope.children_time
- stat_engine.record_metric(metric_specs) do |stat|
+ stat_engine.record_metrics(metric_specs) do |stat|
stat.record_data_point(duration, exclusive)
end
end
View
2 lib/new_relic/agent/stats_engine/gc_profiler.rb
@@ -50,7 +50,7 @@ def record_gc_metric(num_calls, elapsed)
# GC stats are collected into a blamed metric which allows
# us to show the stats controller by controller
NewRelic::Agent.instance.stats_engine \
- .record_metric('GC/cumulative', nil, :scoped => true) do |stat|
+ .record_metrics('GC/cumulative', nil, :scoped => true) do |stat|
stat.record_multiple_data_points(elapsed, num_calls)
end
end
View
6 lib/new_relic/agent/stats_engine/metric_stats.rb
@@ -13,7 +13,7 @@ module MetricStats
#
# This method is thead-safe, and is preferred to the lookup / modify
# method pairs (e.g. get_stats + record_data_point)
- def record_metric(metric_names_or_specs, value=nil, options={}, &blk)
+ def record_metrics(metric_names_or_specs, value=nil, options={}, &blk)
defaults = {
:scoped => false,
:scope => scope_name
@@ -72,14 +72,14 @@ def record_supportability_metrics_timed(metrics)
end_time = Time.now
duration = (end_time - start_time).to_f
ensure
- NewRelic::Agent.agent.stats_engine.record_metric(metrics) do |stat|
+ record_metrics(metrics) do |stat|
stat.record_data_point(duration)
end
end
# Helper for recording a straight value into the count
def record_supportability_metrics_count(value, *metrics)
- NewRelic::Agent.agent.stats_engine.record_metric(metrics) do |stat|
+ record_metrics(metrics) do |stat|
stat.call_count = value
end
end
View
4 test/new_relic/agent/cross_app_monitor_test.rb
@@ -166,7 +166,7 @@ def test_writes_metric
with_default_timings
expected_metric_name = "ClientApplication/#{REQUEST_CROSS_APP_ID}/all"
- NewRelic::Agent.instance.stats_engine.expects(:record_metric). \
+ NewRelic::Agent.instance.stats_engine.expects(:record_metrics). \
with(expected_metric_name, APP_TIME)
when_request_runs
@@ -175,7 +175,7 @@ def test_writes_metric
def test_doesnt_write_metric_if_id_blank
with_default_timings
- NewRelic::Agent.instance.stats_engine.expects(:record_metric).never
+ NewRelic::Agent.instance.stats_engine.expects(:record_metrics).never
when_request_runs(for_id(''))
end
View
2 test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb
@@ -162,7 +162,7 @@ def test_trace_execution_scoped_footer
engine = mocked_object('stat_engine')
scope = mock('scope')
engine.expects(:pop_scope).with('an expected scope', 1.0, 2.0).returns(scope)
- engine.expects(:record_metric).with(metric_specs).multiple_yields(*stats)
+ engine.expects(:record_metrics).with(metric_specs).multiple_yields(*stats)
stats[0].expects(:record_data_point).with(1.0, 0.5)
stats[1].expects(:record_data_point).with(1.0, 0.5)
scope.expects(:children_time).returns(0.5)
View
26 test/new_relic/agent/stats_engine/metric_stats_test.rb
@@ -116,36 +116,36 @@ def test_merge_merges
assert_equal(1, bar_stats.call_count)
end
- def test_record_metric_unscoped_metrics_only_by_default
+ def test_record_metrics_unscoped_metrics_only_by_default
@engine.stubs(:scope_name).returns('scopey')
- @engine.record_metric('foo', 42)
+ @engine.record_metrics('foo', 42)
unscoped_stats = @engine.get_stats('foo', false)
scoped_stats = @engine.get_stats('foo', true, true, 'scopey')
assert_equal(1, unscoped_stats.call_count)
assert_equal(0, scoped_stats.call_count)
end
- def test_record_metric_records_to_scoped_metric_if_requested
+ def test_record_metrics_records_to_scoped_metric_if_requested
@engine.stubs(:scope_name).returns('scopey')
- @engine.record_metric('foo', 42, :scoped => true)
+ @engine.record_metrics('foo', 42, :scoped => true)
unscoped_stats = @engine.get_stats('foo', false)
scoped_stats = @engine.get_stats('foo', true, true, 'scopey')
assert_equal(1, unscoped_stats.call_count)
assert_equal(1, scoped_stats.call_count)
end
- def test_record_metric_elides_scoped_metric_if_not_in_transaction
+ def test_record_metrics_elides_scoped_metric_if_not_in_transaction
@engine.clear_stats
@engine.stubs(:scope_name).returns(nil)
- @engine.record_metric('foo', 42, :scoped => true)
+ @engine.record_metrics('foo', 42, :scoped => true)
unscoped_stats = @engine.get_stats('foo', false)
assert_equal(1, unscoped_stats.call_count)
assert_equal(1, @engine.metrics.size)
end
- def test_record_metric_accepts_explicit_scope
+ def test_record_metrics_accepts_explicit_scope
@engine.stubs(:scope_name).returns('scopey')
- @engine.record_metric('foo', 42, :scoped => true, :scope => 'not scopey')
+ @engine.record_metrics('foo', 42, :scoped => true, :scope => 'not scopey')
unscoped_stats = @engine.get_stats('foo', false)
scoped_stats_scopey = @engine.get_stats('foo', true, true, 'scopey')
scoped_stats_not_scopey = @engine.get_stats('foo', true, true, 'not scopey')
@@ -154,23 +154,23 @@ def test_record_metric_accepts_explicit_scope
assert_equal(1, scoped_stats_not_scopey.call_count)
end
- def test_record_metric_accepts_block
- @engine.record_metric('foo') do |stats|
+ def test_record_metrics_accepts_block
+ @engine.record_metrics('foo') do |stats|
stats.call_count = 999
end
stats = @engine.get_stats_no_scope('foo')
assert_equal(999, stats.call_count)
end
- def test_record_metric_is_thread_safe
+ def test_record_metrics_is_thread_safe
threads = []
nthreads = 25
iterations = 100
nthreads.times do |tid|
threads << Thread.new do
iterations.times do
- @engine.record_metric('m1', 1)
- @engine.record_metric('m2', 1)
+ @engine.record_metrics('m1', 1)
+ @engine.record_metrics('m2', 1)
end
end
end
View
6 test/new_relic/agent_test.rb
@@ -239,7 +239,7 @@ def test_register_report_channel
def test_record_metric
dummy_engine = NewRelic::Agent.agent.stats_engine
- dummy_engine.expects(:record_metric).with('foo', 12)
+ dummy_engine.expects(:record_metrics).with('foo', 12)
NewRelic::Agent.record_metric('foo', 12)
end
@@ -259,15 +259,15 @@ def test_record_metric_accepts_hash
expected_stats.min_call_time = 1
expected_stats.max_call_time = 5
expected_stats.sum_of_squares = 999
- dummy_engine.expects(:record_metric).with('foo', expected_stats)
+ dummy_engine.expects(:record_metrics).with('foo', expected_stats)
NewRelic::Agent.record_metric('foo', stats_hash)
end
def test_increment_metric
dummy_engine = NewRelic::Agent.agent.stats_engine
dummy_stats = mock
dummy_stats.expects(:increment_count).with(12)
- dummy_engine.expects(:record_metric).with('foo').yields(dummy_stats)
+ dummy_engine.expects(:record_metrics).with('foo').yields(dummy_stats)
NewRelic::Agent.increment_metric('foo', 12)
end

0 comments on commit d0ed5af

Please sign in to comment.
Something went wrong with that request. Please try again.