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, #fraction_of, #get_apdex, #is_reset?, #merge, #merge!, #merge_attributes, #midpoint, #min_time_less?, #multiply_by, #reset, #should_replace_begin_time?, #should_replace_end_time?, #split, #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



358
359
360
# File 'lib/new_relic/stats.rb', line 358

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

#inspectObject

outputs a human-readable version of the MethodTraceStats object



363
364
365
# File 'lib/new_relic/stats.rb', line 363

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



329
330
331
332
333
334
335
336
337
338
# File 'lib/new_relic/stats.rb', line 329

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



345
346
347
348
349
350
351
352
353
354
355
# File 'lib/new_relic/stats.rb', line 345

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