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
-
#metric_set ⇒ Object
readonly
Returns the value of attribute metric_set.
-
#slow_jobs ⇒ Object
readonly
A SlowItemSet to store slow jobs in.
-
#slow_transactions ⇒ Object
readonly
A SlowItemSet to store slow transactions in.
-
#timestamp ⇒ Object
readonly
A StoreReportingPeriodTimestamp representing the time that this collection of metrics is for.
Instance Method Summary collapse
-
#initialize(timestamp) ⇒ StoreReportingPeriod
constructor
A new instance of StoreReportingPeriod.
- #jobs ⇒ Object
- #merge_jobs!(jobs) ⇒ Object
-
#merge_metrics!(metrics) ⇒ Object
Add metrics as they are recorded.
- #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) ⇒ 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 = @slow_transactions = SlowItemSet.new @slow_jobs = SlowItemSet.new @metric_set = MetricSet.new @jobs = Hash.new end |
Instance Attribute Details
#metric_set ⇒ Object (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_jobs ⇒ Object (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_transactions ⇒ Object (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 |
#timestamp ⇒ Object (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 end |
Instance Method Details
#jobs ⇒ Object
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_payload ⇒ Object
Retrieve Metrics for reporting
169 170 171 |
# File 'lib/scout_apm/store.rb', line 169 def metrics_payload metric_set.metrics end |
#request_count ⇒ Object
Debug Helpers
189 190 191 192 193 |
# File 'lib/scout_apm/store.rb', line 189 def request_count metrics_payload. select { |,stats| .metric_name =~ /\AController/ }. inject(0) {|sum, (_, stat)| sum + stat.call_count } end |
#slow_jobs_payload ⇒ Object
181 182 183 |
# File 'lib/scout_apm/store.rb', line 181 def slow_jobs_payload slow_jobs.to_a end |
#slow_transactions_payload ⇒ Object
173 174 175 |
# File 'lib/scout_apm/store.rb', line 173 def slow_transactions_payload slow_transactions.to_a end |