Skip to main content

NewCounter

Creates a new labeled counter. Label keys must be set before instantiating a counter. See labeled.SetMetricsKeys for information about to configure that.

def NewCounter(
name: string,
description: string,
scope: promutils.Scope,
opts: ...MetricOption
) - > Counter

Creates a new labeled counter. Label keys must be set before instantiating a counter using labeled.SetMetricsKeys.

Parameters

NameTypeDescription
namestringThe name of the metric. This name will be sanitized to conform to Prometheus metric naming conventions.
descriptionstringA descriptive help text for the metric.
scopepromutils.ScopeThe Prometheus scope to which the counter will be registered.
opts...MetricOptionOptional configurations for the counter, such as EmitUnlabeledMetricOption to emit an unlabeled metric or AdditionalLabelsOption to specify additional labels.

Returns

TypeDescription
CounterA new Counter instance configured with the specified name, description, scope, and options.