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
-
#slow_transactions ⇒ Object
readonly
A SlowTransactionSet object.
-
#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.
-
#merge_metrics!(metrics) ⇒ Object
Add metrics as they are recorded.
- #merge_slow_transactions!(new_transactions) ⇒ Object
-
#metrics_payload ⇒ Object
Retrieve Metrics for reporting.
-
#request_count ⇒ Object
Debug Helpers.
- #slow_transactions_payload ⇒ Object
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 = @slow_transactions = SlowTransactionSet.new @aggregate_metrics = Hash.new end |
Instance Attribute Details
#slow_transactions ⇒ Object (readonly)
A SlowTransactionSet object.
97 98 99 |
# File 'lib/scout_apm/store.rb', line 97 def slow_transactions @slow_transactions end |
#timestamp ⇒ Object (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 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_payload ⇒ Object
Retrieve Metrics for reporting
129 130 131 |
# File 'lib/scout_apm/store.rb', line 129 def metrics_payload @aggregate_metrics end |
#request_count ⇒ Object
Debug Helpers
141 142 143 144 145 |
# File 'lib/scout_apm/store.rb', line 141 def request_count metrics_payload. select { |,stats| .metric_name =~ /\AController/ }. inject(0) {|sum, (_, stat)| sum + stat.call_count } end |
#slow_transactions_payload ⇒ Object
133 134 135 |
# File 'lib/scout_apm/store.rb', line 133 def slow_transactions_payload @slow_transactions.to_a end |