lib/new_relic/stats.rb in newrelic_rpm-2.10.5 vs lib/new_relic/stats.rb in newrelic_rpm-2.10.6

- old
+ new

@@ -24,11 +24,28 @@ end def average_exclusive_time return 0 if call_count == 0 total_exclusive_time / call_count end - + + # merge by adding to average response time + # - used to compose multiple metrics e.g. dispatcher time + mongrel queue time + def sum_merge! (other_stats) + Array(other_stats).each do |s| + self.total_call_time += s.total_call_time + self.total_exclusive_time += s.total_exclusive_time + self.min_call_time += s.min_call_time + self.max_call_time += s.max_call_time + #self.call_count += s.call_count - do not add call count because we are stacking these times on top of each other + self.sum_of_squares += s.sum_of_squares if s.sum_of_squares + self.begin_time = s.begin_time if s.begin_time.to_f < begin_time.to_f || begin_time.to_f == 0.0 + self.end_time = s.end_time if s.end_time.to_f > end_time.to_f + end + + self + end + def merge! (other_stats) Array(other_stats).each do |s| self.total_call_time += s.total_call_time self.total_exclusive_time += s.total_exclusive_time self.min_call_time = s.min_call_time if (s.min_call_time < min_call_time && s.call_count > 0) || call_count == 0 @@ -170,10 +187,10 @@ end # Summary string to facilitate testing def summary format = "%m/%d %I:%M%p" - "[#{Time.at(begin_time).strftime(format)}, #{duration}s. #{call_count} calls; #{to_ms(average_call_time)}ms]" + "[#{Time.at(begin_time).strftime(format)}, #{'%2.3fs' % duration}; #{'%4i' % call_count} calls #{'%4i' % to_ms(average_call_time)} ms]" end # round all of the values to n decimal points def round! self.total_call_time = round_to_3(total_call_time)