Class: OpenTelemetry::Metrics::Instrument::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/metrics/instrument/counter.rb

Overview

No-op implementation of Counter.

Instance Method Summary collapse

Instance Method Details

#add(increment, attributes: {}) ⇒ Object

Increment the Counter by a fixed amount.

Parameters:

  • increment (numeric) —

    The increment amount, which MUST be a non-negative numeric value.

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

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



19
# File 'lib/opentelemetry/metrics/instrument/counter.rb', line 19

def add(increment, attributes: {}); end

#bind(attributes: {}) ⇒ Counter

(Development) Binds a fixed set of attributes to this Counter, returning an instrument whose #add calls associate every measurement with those attributes. Attributes are resolved once at bind time rather than on every recording, avoiding repeated attribute processing and lookup. Passing attributes to #add on the returned bound instrument negates this benefit.

Parameters:

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

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

Returns:

  • (Counter) —

    a bound instrument supporting #add; the no-op implementation returns self.



43
44
45
# File 'lib/opentelemetry/metrics/instrument/counter.rb', line 43

def bind(attributes: {})
  self
end

#enabled? ⇒ Boolean

Returns whether this Counter is enabled for recording measurements.

Instrumentation authors need to call this API each time they record a measurement to ensure they have the most up-to-date value.

Returns:

  • (Boolean) —

    default to true in noop implementation



28
29
30
# File 'lib/opentelemetry/metrics/instrument/counter.rb', line 28

def enabled?
  true
end