Object - observe : Counter

This represents the metric type - counter, that can be only increased by an integer number.

Constructor

__init

(string name, string? desc, map<string> tags)

  • name string
  • Name of the Counter instance.

  • desc string?
  • Description of the Counter 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.

Methods

Register the counter metric instance with the Metric Registry.

Unregister the counter metric instance with the Metric Registry.

Increment the counter's value by an amount.

Resets the counter's value to zero.

Retrieves the counter's current value.

Fields

  • name string
  • Name of the counter metric.

  • description string
  • Description of the counter metric.

  • metricTags map<string>
  • Tags associated with the counter metric.

register

()

returns error?

Register the counter 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

(int amount)

Increment the counter's value by an amount.

Parameters

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

reset

()

Resets the counter's value to zero.

getValue

()

returns int

Retrieves the counter's current value.

  • Return Type

    (int)
  • The current value of the counter.