Class: ScoutApm::RequestHistograms

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/request_histograms.rb

Constant Summary collapse

DEFAULT_HISTOGRAM_SIZE =
50

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(histogram_size = DEFAULT_HISTOGRAM_SIZE) ⇒ RequestHistograms

Returns a new instance of RequestHistograms.



16
17
18
19
# File 'lib/scout_apm/request_histograms.rb', line 16

def initialize(histogram_size = DEFAULT_HISTOGRAM_SIZE)
  @histogram_size = histogram_size
  initialize_histograms_hash
end

Instance Attribute Details

#histogram_sizeObject (readonly)

Returns the value of attribute histogram_size.



14
15
16
# File 'lib/scout_apm/request_histograms.rb', line 14

def histogram_size
  @histogram_size
end

Instance Method Details

#add(item, value) ⇒ Object



25
26
27
# File 'lib/scout_apm/request_histograms.rb', line 25

def add(item, value)
  @histograms[item].add(value)
end

#approximate_quantile_of_value(item, value) ⇒ Object



29
30
31
# File 'lib/scout_apm/request_histograms.rb', line 29

def approximate_quantile_of_value(item, value)
  @histograms[item].approximate_quantile_of_value(value)
end

#each_nameObject



21
22
23
# File 'lib/scout_apm/request_histograms.rb', line 21

def each_name
  @histograms.keys.each { |n| yield n }
end

#initialize_histograms_hashObject



42
43
44
# File 'lib/scout_apm/request_histograms.rb', line 42

def initialize_histograms_hash
  @histograms = Hash.new { |h, k| h[k] = NumericHistogram.new(histogram_size) }
end

#quantile(item, q) ⇒ Object



33
34
35
# File 'lib/scout_apm/request_histograms.rb', line 33

def quantile(item, q)
  @histograms[item].quantile(q)
end

#reset_all!Object

Wipes all histograms, setting them back to empty



38
39
40
# File 'lib/scout_apm/request_histograms.rb', line 38

def reset_all!
  initialize_histograms_hash
end