Class: NewRelic::Histogram

Inherits:
Object show all
Defined in:
lib/new_relic/histogram.rb

Overview

Histogram is used for organizing response times into an ‘Exponential Histogram’. Feature based in part on DHH proposal: 37signals.com/svn/posts/1836-the-problem-with-averages

Histogram builds a set of buckets of geometrically growing size, with the assumption that most apps have long-tail response times, and therefore you need the most granularity at the lowest r/t level.

Defined Under Namespace

Modules: Shim Classes: Bucket

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first_bucket_max = 0.010, bucket_count = 30, multiplier = 1.3) ⇒ Histogram

Histogram uses apdex T / 10 as its minimum bucket size, and grows from there. 30 data points should be adequate resolution.



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/new_relic/histogram.rb', line 69

def initialize(first_bucket_max = 0.010, bucket_count = 30, multiplier = 1.3)
  @buckets = []
  
  min = 0
  max = first_bucket_max
  
   (bucket_count - 1).times do 
    @buckets << Bucket.new(min, max)
    min = max
    max *= multiplier
  end
  @buckets << Bucket.new(max)
end

Instance Attribute Details

#bucketsObject (readonly)

Returns the value of attribute buckets.



65
66
67
# File 'lib/new_relic/histogram.rb', line 65

def buckets
  @buckets
end

Instance Method Details

#process(response_time) ⇒ Object



83
84
85
86
87
88
# File 'lib/new_relic/histogram.rb', line 83

def process(response_time)
  buckets.each do |bucket|
    found = bucket.process(response_time) 
    return if found == 0
  end
end