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.



103
104
105
106
107
108
# File 'lib/scout_apm/store.rb', line 103

def initialize(timestamp)
  @timestamp = timestamp

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

Instance Attribute Details

#slow_transactionsObject (readonly)

A SlowTransactionSet object.



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

def slow_transactions
  @slow_transactions
end

#timestampObject (readonly)

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



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

def timestamp
  @timestamp
end

Instance Method Details

#merge_metrics!(metrics) ⇒ Object

Add metrics as they are recorded



113
114
115
116
# File 'lib/scout_apm/store.rb', line 113

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

#merge_slow_transactions!(new_transactions) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/scout_apm/store.rb', line 118

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



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

def metrics_payload
  @aggregate_metrics
end

#request_countObject

Debug Helpers



141
142
143
144
145
# File 'lib/scout_apm/store.rb', line 141

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

#slow_transactions_payloadObject



133
134
135
# File 'lib/scout_apm/store.rb', line 133

def slow_transactions_payload
  @slow_transactions.to_a
end