Class: OpenTelemetry::SDK::Metrics::Exemplar::AlignedHistogramBucketExemplarReservoir
- Inherits:
-
ExemplarReservoir
- Object
- ExemplarReservoir
- OpenTelemetry::SDK::Metrics::Exemplar::AlignedHistogramBucketExemplarReservoir
- Defined in:
- lib/opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.rb
Overview
AlignedHistogramBucketExemplarReservoir
This Exemplar reservoir stores at most one exemplar per histogram bucket. It uses reservoir sampling within each bucket to ensure uniform distribution of exemplars across the value range.
This is the recommended reservoir for Explicit Bucket Histogram aggregation.
Instance Method Summary collapse
-
#collect(attributes: nil, aggregation_temporality: nil) ⇒ Array<Exemplar>
Collects accumulated exemplars and optionally resets state.
-
#initialize(boundaries: nil) ⇒ AlignedHistogramBucketExemplarReservoir
constructor
A new instance of AlignedHistogramBucketExemplarReservoir.
-
#offer(value: nil, timestamp: nil, attributes: nil, context: nil) ⇒ Object
Offers a measurement to the reservoir for potential sampling.
-
#reset ⇒ Object
Clears all sampled exemplars from the reservoir.
Methods inherited from ExemplarReservoir
Constructor Details
#initialize(boundaries: nil) ⇒ AlignedHistogramBucketExemplarReservoir
Returns a new instance of AlignedHistogramBucketExemplarReservoir.
23 24 25 26 |
# File 'lib/opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.rb', line 23 def initialize(boundaries: nil) @boundaries = boundaries || DEFAULT_BOUNDARIES reset end |
Instance Method Details
#collect(attributes: nil, aggregation_temporality: nil) ⇒ Array<Exemplar>
Collects accumulated exemplars and optionally resets state
45 46 47 48 49 50 |
# File 'lib/opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.rb', line 45 def collect(attributes: nil, aggregation_temporality: nil) exemplars = @exemplar_buckets.map { |bucket| bucket.collect(point_attributes: attributes) } reset if aggregation_temporality == :delta exemplars.compact! exemplars end |
#offer(value: nil, timestamp: nil, attributes: nil, context: nil) ⇒ Object
Offers a measurement to the reservoir for potential sampling
34 35 36 37 38 |
# File 'lib/opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.rb', line 34 def offer(value: nil, timestamp: nil, attributes: nil, context: nil) bucket_index = find_histogram_bucket(value) @exemplar_buckets[bucket_index].offer(value: value, time_unix_nano: , attributes: attributes, context: context) nil end |
#reset ⇒ Object
Clears all sampled exemplars from the reservoir.
53 54 55 |
# File 'lib/opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.rb', line 53 def reset @exemplar_buckets = Array.new(@boundaries.size + 1) { ExemplarBucket.new } end |