Class: ScoutApm::StoreReportingPeriod

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

Overview

One period of Storage. Typically 1 minute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timestamp) ⇒ StoreReportingPeriod

Returns a new instance of StoreReportingPeriod.



99
100
101
102
103
104
# File 'lib/scout_apm/store.rb', line 99

def initialize(timestamp)
  @timestamp = timestamp

  @slow_transactions = SlowTransactionSet.new
  @aggregate_metrics = Hash.new
end

Instance Attribute Details

#slow_transactionsObject (readonly)

An array of SlowTransaction objects



93
94
95
# File 'lib/scout_apm/store.rb', line 93

def slow_transactions
  @slow_transactions
end

#timestampObject (readonly)

A StoreReportingPeriodTimestamp representing the time that this collection of metrics is for



97
98
99
# File 'lib/scout_apm/store.rb', line 97

def timestamp
  @timestamp
end

Instance Method Details

#merge_metrics!(metrics) ⇒ Object

Add metrics as they are recorded



109
110
111
112
# File 'lib/scout_apm/store.rb', line 109

def merge_metrics!(metrics)
  metrics.each { |metric| absorb(metric) }
  self
end

#merge_slow_transactions!(new_transactions) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/scout_apm/store.rb', line 114

def merge_slow_transactions!(new_transactions)
  Array(new_transactions).each do |one_transaction|
    @slow_transactions << one_transaction
  end

  self
end

#metrics_payloadObject

Retrieve Metrics for reporting



125
126
127
# File 'lib/scout_apm/store.rb', line 125

def metrics_payload
  @aggregate_metrics
end

#request_countObject

Debug Helpers



137
138
139
140
141
# File 'lib/scout_apm/store.rb', line 137

def request_count
  metrics_payload.
    select { |meta,stats| meta.metric_name =~ /\AController/ }.
    inject(0) {|sum, (_, stat)| sum + stat.call_count }
end

#slow_transactions_payloadObject



129
130
131
# File 'lib/scout_apm/store.rb', line 129

def slow_transactions_payload
  @slow_transactions.to_a
end