Class: ScoutApm::RequestHistograms
- Inherits:
-
Object
- Object
- ScoutApm::RequestHistograms
- Defined in:
- lib/scout_apm/request_histograms.rb
Constant Summary collapse
- DEFAULT_HISTOGRAM_SIZE =
50
Instance Attribute Summary collapse
-
#histogram_size ⇒ Object
readonly
Returns the value of attribute histogram_size.
Instance Method Summary collapse
- #add(item, value) ⇒ Object
- #approximate_quantile_of_value(item, value) ⇒ Object
- #as_json ⇒ Object
- #each_name ⇒ Object
-
#initialize(histogram_size = DEFAULT_HISTOGRAM_SIZE) ⇒ RequestHistograms
constructor
A new instance of RequestHistograms.
- #initialize_histograms_hash ⇒ Object
- #quantile(item, q) ⇒ Object
- #raw(item) ⇒ Object
-
#reset_all! ⇒ Object
Wipes all histograms, setting them back to empty.
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_size ⇒ Object (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
33 34 35 |
# File 'lib/scout_apm/request_histograms.rb', line 33 def add(item, value) @histograms[item].add(value) end |
#approximate_quantile_of_value(item, value) ⇒ Object
37 38 39 |
# File 'lib/scout_apm/request_histograms.rb', line 37 def approximate_quantile_of_value(item, value) @histograms[item].approximate_quantile_of_value(value) end |
#as_json ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/scout_apm/request_histograms.rb', line 25 def as_json Hash[ @histograms.map{ |key, histogram| [key, histogram.as_json] } ] end |
#each_name ⇒ Object
21 22 23 |
# File 'lib/scout_apm/request_histograms.rb', line 21 def each_name @histograms.keys.each { |n| yield n } end |
#initialize_histograms_hash ⇒ Object
54 55 56 |
# File 'lib/scout_apm/request_histograms.rb', line 54 def initialize_histograms_hash @histograms = Hash.new { |h, k| h[k] = NumericHistogram.new(histogram_size) } end |
#quantile(item, q) ⇒ Object
41 42 43 |
# File 'lib/scout_apm/request_histograms.rb', line 41 def quantile(item, q) @histograms[item].quantile(q) end |
#raw(item) ⇒ Object
50 51 52 |
# File 'lib/scout_apm/request_histograms.rb', line 50 def raw(item) @histograms[item] end |
#reset_all! ⇒ Object
Wipes all histograms, setting them back to empty
46 47 48 |
# File 'lib/scout_apm/request_histograms.rb', line 46 def reset_all! initialize_histograms_hash end |