Skip to main content

Counter

Counter represents a counter labeled with values from the context. See labeled.SetMetricsKeys for information about to configure that.

Attributes

AttributeTypeDescription
CounterVec*prometheus.CounterVecThis embedded field provides the functionality of a Prometheus CounterVec, allowing the Counter to manage a collection of counters with different label values.
Counterprometheus.CounterThis embedded field provides the functionality of a Prometheus Counter, allowing the Counter to increment a single metric.

Methods


Inc()

@classmethod
def Inc(
ctx: context.Context
)

Increments the counter by 1. This method is used to record occurrences of an event.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, which may contain labels to associate with the counter.

Add()

@classmethod
def Add(
ctx: context.Context,
v: float64
)

Adds a specified value to the counter. This method is used to record the magnitude of an event.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, which may contain labels to associate with the counter.
vfloat64The value to add to the counter. This value must be non-negative.