Class: ScoutApm::StoreReportingPeriod
- Inherits:
-
Object
- Object
- ScoutApm::StoreReportingPeriod
- Defined in:
- lib/scout_apm/store.rb
Overview
One period of Storage. Typically 1 minute
Instance Attribute Summary collapse
-
#db_query_metric_set ⇒ Object
readonly
Returns the value of attribute db_query_metric_set.
-
#histograms ⇒ Object
readonly
An Array of HistogramsReport.
-
#job_traces ⇒ Object
readonly
A ScoredItemSet holding the “best” traces for the period.
-
#metric_set ⇒ Object
readonly
Returns the value of attribute metric_set.
-
#request_traces ⇒ Object
readonly
A ScoredItemSet holding the “best” traces for the period.
-
#timestamp ⇒ Object
readonly
A StoreReportingPeriodTimestamp representing the time that this collection of metrics is for.
Instance Method Summary collapse
-
#absorb_metrics!(metrics) ⇒ Object
For absorbing an array of metric => Stat records.
- #db_query_metrics_payload ⇒ Object
-
#initialize(timestamp, context) ⇒ StoreReportingPeriod
constructor
A new instance of StoreReportingPeriod.
- #jobs ⇒ Object
-
#merge(other) ⇒ Object
Merges another StoreReportingPeriod into this one.
- #merge_db_query_metrics!(other_metric_set) ⇒ Object
- #merge_histograms!(new_histograms) ⇒ Object
- #merge_jobs!(jobs) ⇒ Object
-
#merge_metrics!(other_metric_set) ⇒ Object
For merging when you have another metric_set object Makes sure that you don’t duplicate error count records.
- #merge_slow_jobs!(new_jobs) ⇒ Object
- #merge_slow_transactions!(new_transactions) ⇒ Object
-
#metrics_payload ⇒ Object
Retrieve Metrics for reporting.
-
#request_count ⇒ Object
Debug Helpers.
- #slow_jobs_payload ⇒ Object
- #slow_transactions_payload ⇒ Object
Constructor Details
#initialize(timestamp, context) ⇒ StoreReportingPeriod
Returns a new instance of StoreReportingPeriod.
205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/scout_apm/store.rb', line 205 def initialize(, context) @timestamp = @request_traces = ScoredItemSet.new @job_traces = ScoredItemSet.new @histograms = [] @metric_set = MetricSet.new @db_query_metric_set = DbQueryMetricSet.new(context) @jobs = Hash.new end |
Instance Attribute Details
#db_query_metric_set ⇒ Object (readonly)
Returns the value of attribute db_query_metric_set.
203 204 205 |
# File 'lib/scout_apm/store.rb', line 203 def db_query_metric_set @db_query_metric_set end |
#histograms ⇒ Object (readonly)
An Array of HistogramsReport
195 196 197 |
# File 'lib/scout_apm/store.rb', line 195 def histograms @histograms end |
#job_traces ⇒ Object (readonly)
A ScoredItemSet holding the “best” traces for the period
192 193 194 |
# File 'lib/scout_apm/store.rb', line 192 def job_traces @job_traces end |
#metric_set ⇒ Object (readonly)
Returns the value of attribute metric_set.
201 202 203 |
# File 'lib/scout_apm/store.rb', line 201 def metric_set @metric_set end |
#request_traces ⇒ Object (readonly)
A ScoredItemSet holding the “best” traces for the period
189 190 191 |
# File 'lib/scout_apm/store.rb', line 189 def request_traces @request_traces end |
#timestamp ⇒ Object (readonly)
A StoreReportingPeriodTimestamp representing the time that this collection of metrics is for
199 200 201 |
# File 'lib/scout_apm/store.rb', line 199 def @timestamp end |
Instance Method Details
#absorb_metrics!(metrics) ⇒ Object
For absorbing an array of metric => Stat records
236 237 238 239 |
# File 'lib/scout_apm/store.rb', line 236 def absorb_metrics!(metrics) metric_set.absorb_all(metrics) self end |
#db_query_metrics_payload ⇒ Object
311 312 313 |
# File 'lib/scout_apm/store.rb', line 311 def db_query_metrics_payload db_query_metric_set.metrics_to_report end |
#jobs ⇒ Object
303 304 305 |
# File 'lib/scout_apm/store.rb', line 303 def jobs @jobs.values end |
#merge(other) ⇒ Object
Merges another StoreReportingPeriod into this one
220 221 222 223 224 225 226 227 228 229 |
# File 'lib/scout_apm/store.rb', line 220 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) self end |
#merge_db_query_metrics!(other_metric_set) ⇒ Object
248 249 250 251 |
# File 'lib/scout_apm/store.rb', line 248 def merge_db_query_metrics!(other_metric_set) db_query_metric_set.combine!(other_metric_set) self end |
#merge_histograms!(new_histograms) ⇒ Object
281 282 283 284 285 286 287 288 289 290 |
# File 'lib/scout_apm/store.rb', line 281 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 |
#merge_jobs!(jobs) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/scout_apm/store.rb', line 261 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 |
#merge_metrics!(other_metric_set) ⇒ Object
For merging when you have another metric_set object Makes sure that you don’t duplicate error count records
243 244 245 246 |
# File 'lib/scout_apm/store.rb', line 243 def merge_metrics!(other_metric_set) metric_set.combine!(other_metric_set) self end |
#merge_slow_jobs!(new_jobs) ⇒ Object
273 274 275 276 277 278 279 |
# File 'lib/scout_apm/store.rb', line 273 def merge_slow_jobs!(new_jobs) Array(new_jobs).each do |job| job_traces << job end self end |
#merge_slow_transactions!(new_transactions) ⇒ Object
253 254 255 256 257 258 259 |
# File 'lib/scout_apm/store.rb', line 253 def merge_slow_transactions!(new_transactions) Array(new_transactions).each do |one_transaction| request_traces << one_transaction end self end |
#metrics_payload ⇒ Object
Retrieve Metrics for reporting
295 296 297 |
# File 'lib/scout_apm/store.rb', line 295 def metrics_payload metric_set.metrics end |
#request_count ⇒ Object
Debug Helpers
319 320 321 322 323 |
# File 'lib/scout_apm/store.rb', line 319 def request_count metrics_payload. select { |,stats| .metric_name =~ /\AController/ }. inject(0) {|sum, (_, stat)| sum + stat.call_count } end |
#slow_jobs_payload ⇒ Object
307 308 309 |
# File 'lib/scout_apm/store.rb', line 307 def slow_jobs_payload job_traces.to_a end |
#slow_transactions_payload ⇒ Object
299 300 301 |
# File 'lib/scout_apm/store.rb', line 299 def slow_transactions_payload request_traces.to_a end |