This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

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<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 the gauge metric instance with the Metric Registry.

Unregister the counter metric instance with the Metric Registry.

Increment the gauge's value by an amount.

Decrement the gauge's value by an amount.

Sets the instantaneous value for gauge.

Retrieves the gauge's current value.

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

()

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

(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

(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

(float amount)

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.