Class: Gauge

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

Constructor

This instantiates the Gauge object. Name field is mandatory, and description, tags, and statitics config fields are optional and have its own default values when no params are passed.

init (string name, string? desc, map<string>? 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<string>? ()
  • 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

register

Register the gauge metric instance with the Metric Registry.

unregister

Unregister the counter metric instance with the Metric Registry.

increment

Increment the gauge's value by an amount.

decrement

Decrement the gauge's value by an amount.

setValue

Sets the instantaneous value for gauge.

getValue

Retrieves the gauge's current value.

getSnapshot

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

Fields

  • name string
  • Name of the counter metric

  • description string
  • Description of the counter metric

  • metricTags map<string>
  • 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

function 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

function unregister()

Unregister the counter metric instance with the Metric Registry.

increment

function increment(float amount)

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

function decrement(float amount)

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

function setValue(float amount)

Sets the instantaneous value for gauge.

Parameters

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

getValue

function getValue() returns float

Retrieves the gauge's current value.

Return Type

(float)

The current value of the gauge

getSnapshot

function 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