Class: OpenTelemetry::SDK::Metrics::Instrument::UpDownCounter

Inherits:
SynchronousInstrument show all
Defined in:
lib/opentelemetry/sdk/metrics/instrument/up_down_counter.rb

Overview

UpDownCounter is the SDK implementation of Metrics::UpDownCounter.

Instance Method Summary collapse

Methods inherited from SynchronousInstrument

#initialize, #register_with_new_metric_store

Constructor Details

This class inherits a constructor from OpenTelemetry::SDK::Metrics::Instrument::SynchronousInstrument

Instance Method Details

#add(amount, attributes: nil) ⇒ Object

Increment or decrement the UpDownCounter by a fixed amount.

Parameters:

  • amount (Numeric)

    The amount to be added, can be positive, negative or zero.

  • attributes (Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil)

    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).



27
28
29
30
31
32
33
# File 'lib/opentelemetry/sdk/metrics/instrument/up_down_counter.rb', line 27

def add(amount, attributes: nil)
  update(amount, attributes)
  nil
rescue StandardError => e
  OpenTelemetry.handle_error(exception: e)
  nil
end

#instrument_kindSymbol

Returns the instrument kind as a Symbol

Returns:

  • (Symbol)


16
17
18
# File 'lib/opentelemetry/sdk/metrics/instrument/up_down_counter.rb', line 16

def instrument_kind
  :up_down_counter
end