Class: ScoutApm::MetricSet
- Inherits:
-
Object
- Object
- ScoutApm::MetricSet
- Defined in:
- lib/scout_apm/metric_set.rb
Constant Summary collapse
- PASSTHROUGH_METRICS =
We can’t aggregate CPU, Memory, Capacity, or Controller, so pass through these metrics directly TODO: Figure out a way to not have this duplicate what’s in Samplers, and also on server’s ingest
["CPU", "Memory", "Instance", "Controller", "SlowTransaction"]
Instance Attribute Summary collapse
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
Instance Method Summary collapse
-
#absorb(metric) ⇒ Object
Absorbs a single new metric into the aggregates.
- #absorb_all(metrics) ⇒ Object
- #combine!(other) ⇒ Object
-
#initialize ⇒ MetricSet
constructor
A new instance of MetricSet.
Constructor Details
#initialize ⇒ MetricSet
Returns a new instance of MetricSet.
9 10 11 |
# File 'lib/scout_apm/metric_set.rb', line 9 def initialize @metrics = Hash.new end |
Instance Attribute Details
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
7 8 9 |
# File 'lib/scout_apm/metric_set.rb', line 7 def metrics @metrics end |
Instance Method Details
#absorb(metric) ⇒ Object
Absorbs a single new metric into the aggregates
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/scout_apm/metric_set.rb', line 18 def absorb(metric) , stat = metric if PASSTHROUGH_METRICS.include?(.type) # Leave as-is, don't attempt to combine into an /all key @metrics[] ||= MetricStats.new @metrics[].combine!(stat) elsif .type == "Errors" # Sadly special cased, we want both raw and aggregate values @metrics[] ||= MetricStats.new @metrics[].combine!(stat) = MetricMeta.new("Errors/Request", :scope => .scope) @metrics[] ||= MetricStats.new @metrics[].combine!(stat) else # Combine down to a single /all key = MetricMeta.new("#{meta.type}/all", :scope => .scope) @metrics[] ||= MetricStats.new @metrics[].combine!(stat) end end |
#absorb_all(metrics) ⇒ Object
13 14 15 |
# File 'lib/scout_apm/metric_set.rb', line 13 def absorb_all(metrics) Array(metrics).each { |m| absorb(m) } end |
#combine!(other) ⇒ Object
39 40 41 42 |
# File 'lib/scout_apm/metric_set.rb', line 39 def combine!(other) absorb_all(other.metrics) self end |