Class: ScoutApm::Instruments::PercentileSampler
- Inherits:
-
Object
- Object
- ScoutApm::Instruments::PercentileSampler
- Defined in:
- lib/scout_apm/instruments/percentile_sampler.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#percentiles ⇒ Object
readonly
Returns the value of attribute percentiles.
Instance Method Summary collapse
- #human_name ⇒ Object
-
#initialize(logger, percentiles) ⇒ PercentileSampler
constructor
A new instance of PercentileSampler.
-
#metrics(time) ⇒ Object
Gets the 95th%ile for the time requested.
Constructor Details
#initialize(logger, percentiles) ⇒ PercentileSampler
Returns a new instance of PercentileSampler.
8 9 10 11 |
# File 'lib/scout_apm/instruments/percentile_sampler.rb', line 8 def initialize(logger, percentiles) @logger = logger @percentiles = Array(percentiles) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/scout_apm/instruments/percentile_sampler.rb', line 4 def logger @logger end |
#percentiles ⇒ Object (readonly)
Returns the value of attribute percentiles.
6 7 8 |
# File 'lib/scout_apm/instruments/percentile_sampler.rb', line 6 def percentiles @percentiles end |
Instance Method Details
#human_name ⇒ Object
13 14 15 |
# File 'lib/scout_apm/instruments/percentile_sampler.rb', line 13 def human_name "Percentiles" end |
#metrics(time) ⇒ Object
Gets the 95th%ile for the time requested
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/scout_apm/instruments/percentile_sampler.rb', line 18 def metrics(time) ms = {} histos = ScoutApm::Agent.instance.request_histograms_by_time[time] histos.each_name do |name| percentiles.each do |percentile| = MetricMeta.new("Percentile/#{percentile}/#{name}") stat = MetricStats.new stat.update!(histos.quantile(name, percentile)) ms[] = stat end end # Wipe the histograms we just collected data on ScoutApm::Agent.instance.request_histograms_by_time.delete(time) ms end |