Sha256: 4291f566a5f8b817fe2eeb8d7eedaf43b3d07af149f332fa7c345a1759c9fd16
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true # Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 module OpenTelemetry module Internal # @api private class ProxyInstrument def initialize(kind, name, unit, desc, callable) @kind = kind @name = name @unit = unit @desc = desc @callable = callable @delegate = nil end def upgrade_with(meter) @delegate = case @kind when :counter, :histogram, :up_down_counter meter.send("create_#{@kind}", @name, unit: @unit, description: @desc) when :observable_counter, :observable_gauge, :observable_up_down_counter meter.send("create_#{@kind}", @name, unit: @unit, description: @desc, callback: @callback) end end def add(amount, attributes: nil) @delegate&.add(amount, attributes: attributes) end def record(amount, attributes: nil) @delegate&.record(amount, attributes: attributes) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
opentelemetry-metrics-api-0.1.1 | lib/opentelemetry/internal/proxy_instrument.rb |
opentelemetry-metrics-api-0.1.0 | lib/opentelemetry/internal/proxy_instrument.rb |