lib/new_relic/stats.rb in newrelic_rpm-3.1.0 vs lib/new_relic/stats.rb in newrelic_rpm-3.1.1.beta1
- old
+ new
@@ -1,14 +1,15 @@
module NewRelic
module Stats
-
+
+ # a stat is absent if its call count equals zero
def absent?
- # guess on absent values
call_count == 0
end
-
+
+ # outputs a useful human-readable time given a value in milliseconds
def time_str(value_ms)
case
when value_ms >= 10000
"%.1f s" % (value_ms / 1000.0)
when value_ms >= 5000
@@ -24,11 +25,11 @@
0.0
else
numerator.to_f / denominator
end
end
-
+
def average_call_time
checked_calculation(total_call_time, call_count)
end
def average_exclusive_time
checked_calculation(total_exclusive_time, call_count)
@@ -334,11 +335,14 @@
@sum_of_squares += (value * value)
self
end
alias trace_call record_data_point
-
+
+ # Records multiple data points as one method call - this handles
+ # all the aggregation that would be done with multiple
+ # record_data_point calls
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
@@ -346,15 +350,17 @@
@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
-
+
+ # increments the call_count by one
def increment_count(value = 1)
@call_count += value
end
-
+
+ # outputs a human-readable version of the MethodTraceStats object
def inspect
"#<NewRelic::MethodTraceStats #{summary} >"
end
end
@@ -367,9 +373,12 @@
end
def trace_call(call_time, exclusive_time = call_time)
unscoped_stats.trace_call call_time, exclusive_time
super call_time, exclusive_time
end
+ # Records multiple data points as one method call - this handles
+ # all the aggregation that would be done with multiple
+ # trace_call calls
def record_multiple_data_points(total_value, count=1)
unscoped_stats.record_multiple_data_points(total_value, count)
super total_value, count
end
end