Object - observe : Gauge

This represents the metric type - gauge, that can hold instantaneous, increased or decreased value during the usage.

Constructor

__init

(string name, string desc, map tags, StatisticConfig[]? statisticConfig)

  • name string
  • Name of the Gauge instance.

  • desc string
  • Description of the Gauge instance. If no description is provided, the the default empty string will be used.

  • tags map ()
  • The key/value pair of Tags. If no tags are provided, the default nil value will be used.

  • statisticConfig StatisticConfig[]? ()
  • Statistics configurations array is used for statistics calculation. In case if empty statistics configurations array is passed, then statistics calculation will be disabled. If nil () is passed, then default statistics configs will be used for the statitics calculation.

Methods

Fields

  • name string
  • Name of the counter metric.

  • description string
  • Description of the counter metric.

  • metricTags map
  • Tags associated with the counter metric.

  • statisticConfigs StatisticConfig[]
  • Array of StatisticConfig objects which defines about the statistical calculation of the gauge during its usage.

register

()

returns error

Register the gauge metric instance with the Metric Registry.

  • Return Type

    (error)
  • Returns error if there is any metric registered already with the same name but different parameters or in a different kind.

unregister

Unregister the counter metric instance with the Metric Registry.

increment

Increment the gauge's value by an amount.

Parameters

  • amount float (default 1.0)
  • The amount by which the value of gauge needs to be increased. The amount is defaulted as 1.0 and will be used if there is no amount passed in.

decrement

Decrement the gauge's value by an amount.

Parameters

  • amount float (default 1.0)
  • The amount by which the value of gauge needs to be decreased. The amount is defaulted as 1.0 and will be used if there is no amount passed in.

setValue

Sets the instantaneous value for gauge.

Parameters

  • amount float
  • The instantaneous value that needs to be set as gauge value.

getValue

()

returns float

Retrieves the gauge's current value.

  • Return Type

    (float)
  • The current value of the gauge.

getSnapshot

()

returns Snapshot[]?

Retrieves statistics snapshots based on the statistics configs of the gauge.

  • Return Type

    (Snapshot[]?)
  • Array of the statistics snapshots. If there is no statisticsConfigs provided, then it will be nil.