Class: NewRelic::Histogram

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

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.



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

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.



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

def buckets
  @buckets
end

Instance Method Details

#process(response_time) ⇒ Object



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

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