Class: OpenTelemetry::SDK::Metrics::Instrument::Histogram

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

Overview

Histogram is the SDK implementation of Metrics::Histogram.

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

#instrument_kindSymbol

Returns the instrument kind as a Symbol

Returns:

  • (Symbol)


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

def instrument_kind
  :histogram
end

#record(amount, attributes: {}) ⇒ Object

Updates the statistics with the specified amount.

Parameters:

  • amount (numeric)

    The amount of the Measurement, 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).



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

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