Class: HeimdallApm::MetricStats
- Inherits:
-
Object
- Object
- HeimdallApm::MetricStats
- Defined in:
- lib/heimdall_apm/metric_stats.rb
Overview
Stats associated with a single metric (used in metrics Hashs as value where keys are the metrics names)
Instance Attribute Summary collapse
-
#call_count ⇒ Object
Returns the value of attribute call_count.
-
#max_call_time ⇒ Object
Returns the value of attribute max_call_time.
-
#min_call_time ⇒ Object
Returns the value of attribute min_call_time.
-
#total_call_time ⇒ Object
Returns the value of attribute total_call_time.
-
#total_exclusive_time ⇒ Object
Returns the value of attribute total_exclusive_time.
Instance Method Summary collapse
-
#initialize(scoped: false) ⇒ MetricStats
constructor
If this metric is scoped inside another, use exclusive time for min/max.
- #update(call_time, exclusive_time = nil) ⇒ Object
Constructor Details
#initialize(scoped: false) ⇒ MetricStats
If this metric is scoped inside another, use exclusive time for min/max. Non-scoped metrics (like Controller) track the total call time.
14 15 16 17 18 19 20 21 |
# File 'lib/heimdall_apm/metric_stats.rb', line 14 def initialize(scoped: false) @scoped = scoped @call_count = 0 @total_call_time = 0.0 @total_exclusive_time = 0.0 @min_call_time = 0.0 @max_call_time = 0.0 end |
Instance Attribute Details
#call_count ⇒ Object
Returns the value of attribute call_count.
6 7 8 |
# File 'lib/heimdall_apm/metric_stats.rb', line 6 def call_count @call_count end |
#max_call_time ⇒ Object
Returns the value of attribute max_call_time.
10 11 12 |
# File 'lib/heimdall_apm/metric_stats.rb', line 10 def max_call_time @max_call_time end |
#min_call_time ⇒ Object
Returns the value of attribute min_call_time.
9 10 11 |
# File 'lib/heimdall_apm/metric_stats.rb', line 9 def min_call_time @min_call_time end |
#total_call_time ⇒ Object
Returns the value of attribute total_call_time.
7 8 9 |
# File 'lib/heimdall_apm/metric_stats.rb', line 7 def total_call_time @total_call_time end |
#total_exclusive_time ⇒ Object
Returns the value of attribute total_exclusive_time.
8 9 10 |
# File 'lib/heimdall_apm/metric_stats.rb', line 8 def total_exclusive_time @total_exclusive_time end |
Instance Method Details
#update(call_time, exclusive_time = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/heimdall_apm/metric_stats.rb', line 23 def update(call_time, exclusive_time = nil) self.call_count += 1 self.total_call_time += call_time self.total_exclusive_time += exclusive_time t = @scoped ? exclusive_time : call_time self.min_call_time = t if call_count == 0 || t < min_call_time self.max_call_time = t if t > max_call_time end |