Class: ScoutApm::ExternalServiceMetricStats
- Inherits:
-
Object
- Object
- ScoutApm::ExternalServiceMetricStats
- Defined in:
- lib/scout_apm/external_service_metric_stats.rb
Constant Summary collapse
- DEFAULT_HISTOGRAM_SIZE =
50
Instance Attribute Summary collapse
-
#call_count ⇒ Object
readonly
Returns the value of attribute call_count.
-
#call_time ⇒ Object
readonly
Returns the value of attribute call_time.
-
#domain_name ⇒ Object
readonly
Returns the value of attribute domain_name.
-
#histogram ⇒ Object
readonly
Returns the value of attribute histogram.
-
#max_call_time ⇒ Object
readonly
Returns the value of attribute max_call_time.
-
#min_call_time ⇒ Object
readonly
Returns the value of attribute min_call_time.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#transaction_count ⇒ Object
readonly
Returns the value of attribute transaction_count.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#combine!(other) ⇒ Object
Combine data from another ExternalServiceMetricStats into
self
. -
#increment_transaction_count! ⇒ Object
Called by the Set on each ExternalServiceMetricStats object that it holds, only once during the recording of a transaction.
-
#initialize(domain_name, operation, scope, call_count, call_time) ⇒ ExternalServiceMetricStats
constructor
A new instance of ExternalServiceMetricStats.
-
#key ⇒ Object
Merge data in this scope.
Constructor Details
#initialize(domain_name, operation, scope, call_count, call_time) ⇒ ExternalServiceMetricStats
Returns a new instance of ExternalServiceMetricStats.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 20 def initialize(domain_name, operation, scope, call_count, call_time) @domain_name = domain_name @operation = operation @call_count = call_count @call_time = call_time @min_call_time = call_time @max_call_time = call_time # This histogram is for call_time @histogram = NumericHistogram.new(DEFAULT_HISTOGRAM_SIZE) @histogram.add(call_time) @transaction_count = 0 @scope = scope end |
Instance Attribute Details
#call_count ⇒ Object (readonly)
Returns the value of attribute call_count.
12 13 14 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 12 def call_count @call_count end |
#call_time ⇒ Object (readonly)
Returns the value of attribute call_time.
13 14 15 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 13 def call_time @call_time end |
#domain_name ⇒ Object (readonly)
Returns the value of attribute domain_name.
6 7 8 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 6 def domain_name @domain_name end |
#histogram ⇒ Object (readonly)
Returns the value of attribute histogram.
18 19 20 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 18 def histogram @histogram end |
#max_call_time ⇒ Object (readonly)
Returns the value of attribute max_call_time.
16 17 18 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 16 def max_call_time @max_call_time end |
#min_call_time ⇒ Object (readonly)
Returns the value of attribute min_call_time.
15 16 17 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 15 def min_call_time @min_call_time end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
7 8 9 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 7 def operation @operation end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
8 9 10 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 8 def scope @scope end |
#transaction_count ⇒ Object (readonly)
Returns the value of attribute transaction_count.
10 11 12 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 10 def transaction_count @transaction_count end |
Instance Method Details
#as_json ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 59 def as_json json_attributes = [ :domain_name, :operation, :scope, :transaction_count, :call_count, :histogram, :call_time, :max_call_time, :min_call_time, ] ScoutApm::AttributeArranger.call(self, json_attributes) end |
#combine!(other) ⇒ Object
Combine data from another ExternalServiceMetricStats into self
. Modifies and returns self
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 45 def combine!(other) return self if other == self @transaction_count += other.transaction_count @call_count += other.call_count @call_time += other.call_time @min_call_time = other.min_call_time if @min_call_time.zero? or other.min_call_time < @min_call_time @max_call_time = other.max_call_time if other.max_call_time > @max_call_time @histogram.combine!(other.histogram) self end |
#increment_transaction_count! ⇒ Object
Called by the Set on each ExternalServiceMetricStats object that it holds, only once during the recording of a transaction.
Don’t call elsewhere, and don’t set to 1 in the initializer.
81 82 83 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 81 def increment_transaction_count! @transaction_count += 1 end |
#key ⇒ Object
Merge data in this scope. Used in ExternalServiceMetricSet
40 41 42 |
# File 'lib/scout_apm/external_service_metric_stats.rb', line 40 def key @key ||= [domain_name, operation, scope] end |