Class: NewRelic::MethodTraceStats

Inherits:
StatsBase
  • Object
show all
Defined in:
lib/new_relic/stats.rb

Overview

Statistics used to track the performance of traced methods

Direct Known Subclasses

Agent::SqlTrace, ScopedMethodTraceStats

Instance Attribute Summary

Attributes inherited from StatsBase

#call_count, #max_call_time, #min_call_time, #sum_of_squares, #total_call_time, #total_exclusive_time

Instance Method Summary collapse

Methods inherited from StatsBase

#begin_time, #begin_time=, #end_time, #end_time=, #freeze, #initialize, #to_json

Methods included from Stats

#absent?, #apdex_score, #as_percentage, #as_percentage_of, #average_call_time, #average_exclusive_time, #calls_per_minute, #checked_calculation, #duration, #exclusive_time_percentage, #expand_min_max_to, #get_apdex, #is_reset?, #merge, #merge!, #merge_attributes, #midpoint, #min_time_less?, #multiply_by, #reset, #should_replace_begin_time?, #should_replace_end_time?, #stack_min_max_from, #standard_deviation, #sum_attributes, #sum_merge!, #summary, #time_percentage, #time_str, #to_s, #total_call_time_per_minute, #update_boundaries, #update_totals

Constructor Details

This class inherits a constructor from NewRelic::StatsBase

Instance Method Details

#increment_count(value = 1) ⇒ Object

increments the call_count by one



305
306
307
# File 'lib/new_relic/stats.rb', line 305

def increment_count(value = 1)
  @call_count += value
end

#inspectObject

outputs a human-readable version of the MethodTraceStats object



310
311
312
# File 'lib/new_relic/stats.rb', line 310

def inspect
  "#<NewRelic::MethodTraceStats #{summary} >"
end

#record_data_point(value, exclusive_time = value) ⇒ Object Also known as: trace_call

record a single data point into the statistical gatherer. The gatherer will aggregate all data points collected over a specified period and upload its data to the NewRelic server



276
277
278
279
280
281
282
283
284
285
# File 'lib/new_relic/stats.rb', line 276

def record_data_point(value, exclusive_time = value)
  @call_count += 1
  @total_call_time += value
  @min_call_time = value if value < @min_call_time || @call_count == 1
  @max_call_time = value if value > @max_call_time
  @total_exclusive_time += exclusive_time

  @sum_of_squares += (value * value)
  self
end

#record_multiple_data_points(total_value, count = 1) ⇒ Object

Records multiple data points as one method call - this handles all the aggregation that would be done with multiple record_data_point calls



292
293
294
295
296
297
298
299
300
301
302
# File 'lib/new_relic/stats.rb', line 292

def record_multiple_data_points(total_value, count=1)
  return record_data_point(total_value) if count == 1
  @call_count += count
  @total_call_time += total_value
  avg_val = total_value / count
  @min_call_time = avg_val if avg_val < @min_call_time || @call_count == count
  @max_call_time = avg_val if avg_val > @max_call_time
  @total_exclusive_time += total_value
  @sum_of_squares += (avg_val * avg_val) * count
  self
end