Class: Sentry::Metrics::LocalAggregator
- Inherits:
-
Object
- Object
- Sentry::Metrics::LocalAggregator
- Defined in:
- lib/sentry/metrics/local_aggregator.rb
Instance Attribute Summary collapse
-
#buckets ⇒ Object
readonly
exposed only for testing.
Instance Method Summary collapse
- #add(key, value) ⇒ Object
-
#initialize ⇒ LocalAggregator
constructor
A new instance of LocalAggregator.
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ LocalAggregator
Returns a new instance of LocalAggregator.
9 10 11 |
# File 'lib/sentry/metrics/local_aggregator.rb', line 9 def initialize @buckets = {} end |
Instance Attribute Details
#buckets ⇒ Object (readonly)
exposed only for testing
7 8 9 |
# File 'lib/sentry/metrics/local_aggregator.rb', line 7 def buckets @buckets end |
Instance Method Details
#add(key, value) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sentry/metrics/local_aggregator.rb', line 13 def add(key, value) if @buckets[key] @buckets[key].add(value) else @buckets[key] = GaugeMetric.new(value) end end |
#to_hash ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sentry/metrics/local_aggregator.rb', line 21 def to_hash return nil if @buckets.empty? @buckets.map do |bucket_key, metric| type, key, unit, = bucket_key payload_key = "#{type}:#{key}@#{unit}" payload_value = { tags: (), min: metric.min, max: metric.max, count: metric.count, sum: metric.sum } [payload_key, payload_value] end.to_h end |