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.



122
123
124
125
126
127
128
129
130
# File 'lib/scout_apm/store.rb', line 122

def initialize(timestamp)
  @timestamp = timestamp

  @slow_transactions = SlowItemSet.new
  @slow_jobs = SlowItemSet.new

  @metric_set = MetricSet.new
  @jobs = Hash.new
end

Instance Attribute Details

#metric_setObject (readonly)

Returns the value of attribute metric_set.



120
121
122
# File 'lib/scout_apm/store.rb', line 120

def metric_set
  @metric_set
end

#slow_jobsObject (readonly)

A SlowItemSet to store slow jobs in



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

def slow_jobs
  @slow_jobs
end

#slow_transactionsObject (readonly)

A SlowItemSet to store slow transactions in



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

def slow_transactions
  @slow_transactions
end

#timestampObject (readonly)

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



118
119
120
# File 'lib/scout_apm/store.rb', line 118

def timestamp
  @timestamp
end

Instance Method Details

#jobsObject



177
178
179
# File 'lib/scout_apm/store.rb', line 177

def jobs
  @jobs.values
end

#merge_jobs!(jobs) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
# File 'lib/scout_apm/store.rb', line 148

def merge_jobs!(jobs)
  jobs.each do |job|
    if @jobs.has_key?(job)
      @jobs[job].combine!(job)
    else
      @jobs[job] = job
    end
  end

  self
end

#merge_metrics!(metrics) ⇒ Object

Add metrics as they are recorded



135
136
137
138
# File 'lib/scout_apm/store.rb', line 135

def merge_metrics!(metrics)
  metric_set.absorb_all(metrics)
  self
end

#merge_slow_jobs!(new_jobs) ⇒ Object



160
161
162
163
164
# File 'lib/scout_apm/store.rb', line 160

def merge_slow_jobs!(new_jobs)
  Array(new_jobs).each do |job|
    slow_jobs << job
  end
end

#merge_slow_transactions!(new_transactions) ⇒ Object



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

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



169
170
171
# File 'lib/scout_apm/store.rb', line 169

def metrics_payload
  metric_set.metrics
end

#request_countObject

Debug Helpers



189
190
191
192
193
# File 'lib/scout_apm/store.rb', line 189

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

#slow_jobs_payloadObject



181
182
183
# File 'lib/scout_apm/store.rb', line 181

def slow_jobs_payload
  slow_jobs.to_a
end

#slow_transactions_payloadObject



173
174
175
# File 'lib/scout_apm/store.rb', line 173

def slow_transactions_payload
  slow_transactions.to_a
end