Class: ScoutApm::TransactionTimeConsumed
- Inherits:
-
Object
- Object
- ScoutApm::TransactionTimeConsumed
- Defined in:
- lib/scout_apm/transaction_time_consumed.rb
Defined Under Namespace
Classes: TotalTimeRecord
Instance Method Summary collapse
- #add(item, duration) ⇒ Object
- #call_count_for(item) ⇒ Object
-
#initialize ⇒ TransactionTimeConsumed
constructor
A new instance of TransactionTimeConsumed.
- #percent_of_total(item) ⇒ Object
- #total_time_for(item) ⇒ Object
Constructor Details
#initialize ⇒ TransactionTimeConsumed
Returns a new instance of TransactionTimeConsumed.
13 14 15 16 |
# File 'lib/scout_apm/transaction_time_consumed.rb', line 13 def initialize @total_duration = 0.0 @endpoints = Hash.new { |h, k| h[k] = TotalTimeRecord.new } end |
Instance Method Details
#add(item, duration) ⇒ Object
18 19 20 21 |
# File 'lib/scout_apm/transaction_time_consumed.rb', line 18 def add(item, duration) @total_duration += duration.to_f @endpoints[item].add(duration.to_f) end |
#call_count_for(item) ⇒ Object
35 36 37 |
# File 'lib/scout_apm/transaction_time_consumed.rb', line 35 def call_count_for(item) @endpoints[item].count end |
#percent_of_total(item) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/scout_apm/transaction_time_consumed.rb', line 23 def percent_of_total(item) if total_duration == 0.0 0 else @endpoints[item].total_duration / total_duration end end |
#total_time_for(item) ⇒ Object
31 32 33 |
# File 'lib/scout_apm/transaction_time_consumed.rb', line 31 def total_time_for(item) @endpoints[item].total_duration end |