class ScoutApm::StoreReportingPeriod
One period of Storage. Typically 1 minute
Attributes
An Array of HistogramsReport
A ScoredItemSet
holding the “best” traces for the period
A ScoredItemSet
holding the “best” traces for the period
A StoreReportingPeriodTimestamp
representing the time that this collection of metrics is for
Public Class Methods
Source
# File lib/scout_apm/store.rb, line 218 def initialize(timestamp, context) @timestamp = timestamp @context = context @request_traces = ScoredItemSet.new(context.config.value('max_traces')) @job_traces = ScoredItemSet.new(context.config.value('max_traces')) @histograms = [] @metric_set = MetricSet.new @db_query_metric_set = DbQueryMetricSet.new(context) @external_service_metric_set = ExternalServiceMetricSet.new(context) @jobs = Hash.new end
Public Instance Methods
Source
# File lib/scout_apm/store.rb, line 257 def absorb_metrics!(metrics) metric_set.absorb_all(metrics) self end
For absorbing an array of metric {Meta => Stat} records
Source
# File lib/scout_apm/store.rb, line 341 def db_query_metrics_payload db_query_metric_set.metrics_to_report end
Source
# File lib/scout_apm/store.rb, line 345 def external_service_metrics_payload external_service_metric_set.metrics_to_report end
Source
# File lib/scout_apm/store.rb, line 240 def merge(other) self. merge_metrics!(other.metric_set). merge_slow_transactions!(other.slow_transactions_payload). merge_jobs!(other.jobs). merge_slow_jobs!(other.slow_jobs_payload). merge_histograms!(other.histograms). merge_db_query_metrics!(other.db_query_metric_set). merge_external_service_metrics!(other.external_service_metric_set) self end
Merges another StoreReportingPeriod
into this one
Source
# File lib/scout_apm/store.rb, line 269 def merge_db_query_metrics!(other_metric_set) db_query_metric_set.combine!(other_metric_set) self end
Source
# File lib/scout_apm/store.rb, line 274 def merge_external_service_metrics!(other_metric_set) if other_metric_set.nil? logger.debug("Missing other_metric_set for merge_external_service_metrics - skipping.") else external_service_metric_set.combine!(other_metric_set) end self end
Source
# File lib/scout_apm/store.rb, line 311 def merge_histograms!(new_histograms) new_histograms = Array(new_histograms) @histograms = (histograms + new_histograms). group_by { |histo| histo.name }. map { |(_, histos)| histos.inject { |merged, histo| merged.combine!(histo) } } self end
Source
# File lib/scout_apm/store.rb, line 291 def merge_jobs!(jobs) Array(jobs).each do |job| if @jobs.has_key?(job) @jobs[job].combine!(job) else @jobs[job] = job end end self end
Source
# File lib/scout_apm/store.rb, line 264 def merge_metrics!(other_metric_set) metric_set.combine!(other_metric_set) self end
For merging when you have another metric_set
object Makes sure that you don’t duplicate error count records
Source
# File lib/scout_apm/store.rb, line 303 def merge_slow_jobs!(new_jobs) Array(new_jobs).each do |job| job_traces << job end self end
Source
# File lib/scout_apm/store.rb, line 283 def merge_slow_transactions!(new_transactions) Array(new_transactions).each do |one_transaction| request_traces << one_transaction end self end
Source
# File lib/scout_apm/store.rb, line 325 def metrics_payload metric_set.metrics end
Retrieve Metrics for reporting
Source
# File lib/scout_apm/store.rb, line 353 def request_count metrics_payload. select { |meta,stats| meta.metric_name =~ /\AController/ }. inject(0) {|sum, (_, stat)| sum + stat.call_count } end
Debug
Helpers
Source
# File lib/scout_apm/store.rb, line 337 def slow_jobs_payload job_traces.to_a end
Source
# File lib/scout_apm/store.rb, line 329 def slow_transactions_payload request_traces.to_a end