Object - observe : Counter

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



(string name, string desc, map 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 ()
  • The key/value pair of Tags. If no tags are provided, the default nil value will be used.



  • name string
  • Name of the counter metric.

  • description string
  • Description of the counter metric.

  • metricTags map
  • Tags associated with the counter metric.



returns error

Register the counter metric instance with the Metric Registry.

  • Return Type

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


Unregister the counter metric instance with the Metric Registry.


Increment the counter's value by an amount.


  • 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.


Resets the counter's value to zero.



returns int

Retrieves the counter's current value.

  • Return Type

  • The current value of the counter.