Class: OpenTelemetry::SDK::Metrics::Exemplar::ExemplarBucket
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Metrics::Exemplar::ExemplarBucket
- Defined in:
- lib/opentelemetry/sdk/metrics/exemplar/exemplar_bucket.rb
Overview
ExemplarBucket Stores a single exemplar measurement and manages its lifecycle
Instance Method Summary collapse
-
#collect(point_attributes:) ⇒ Exemplar?
May return an Exemplar and resets the bucket for the next sampling period.
-
#initialize ⇒ ExemplarBucket
constructor
A new instance of ExemplarBucket.
-
#offer(value:, time_unix_nano:, attributes:, context:) ⇒ Object
Offers a measurement to be sampled.
Constructor Details
#initialize ⇒ ExemplarBucket
Returns a new instance of ExemplarBucket.
14 15 16 |
# File 'lib/opentelemetry/sdk/metrics/exemplar/exemplar_bucket.rb', line 14 def initialize reset end |
Instance Method Details
#collect(point_attributes:) ⇒ Exemplar?
May return an Exemplar and resets the bucket for the next sampling period
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/opentelemetry/sdk/metrics/exemplar/exemplar_bucket.rb', line 43 def collect(point_attributes:) return nil unless @offered filtered_attributes = (@attributes.reject { |k, _v| point_attributes.key?(k) } if @attributes && point_attributes) exemplar = Exemplar.new( filtered_attributes, @value, @time_unix_nano, @span_id, @trace_id ) reset exemplar end |
#offer(value:, time_unix_nano:, attributes:, context:) ⇒ Object
Offers a measurement to be sampled
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/opentelemetry/sdk/metrics/exemplar/exemplar_bucket.rb', line 24 def offer(value:, time_unix_nano:, attributes:, context:) @value = value @time_unix_nano = time_unix_nano @attributes = attributes span = ::OpenTelemetry::Trace.current_span(context) span_context = span.context if span_context.valid? @span_id = span_context.span_id @trace_id = span_context.trace_id end @offered = true end |