Sha256: 415f8c81cac773052493abce6b8012fb8f628e7a66c60375518101446738ef1e
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
# frozen_string_literal: true # Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 module OpenTelemetry module SDK module Metrics module Instrument # {Gauge} is the SDK implementation of {OpenTelemetry::Metrics::Gauge}. class Gauge < OpenTelemetry::SDK::Metrics::Instrument::SynchronousInstrument # Returns the instrument kind as a Symbol # # @return [Symbol] def instrument_kind :gauge end # Record the absolute value of the Gauge. # # @param [numeric] value The current absolute value. # @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes # Values must be non-nil and (array of) string, boolean or numeric type. # Array values must not contain nil elements and all elements must be of # the same basic type (string, numeric, boolean). def record(value, attributes: {}) # TODO: When the metrics SDK stabilizes and is merged into the main SDK, # we can leverage the SDK Internal validation classes to enforce this: # https://github.com/open-telemetry/opentelemetry-ruby/blob/6bec625ef49004f364457c26263df421526b60d6/sdk/lib/opentelemetry/sdk/internal.rb#L47 update(value, attributes) nil rescue StandardError => e OpenTelemetry.handle_error(exception: e) nil end private def default_aggregation OpenTelemetry::SDK::Metrics::Aggregation::LastValue.new end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opentelemetry-metrics-sdk-0.5.0 | lib/opentelemetry/sdk/metrics/instrument/gauge.rb |