Skip to main content

NewStopWatch

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

def NewStopWatch(
name: string,
description: string,
scale: time.Duration,
scope: promutils.Scope,
opts: ...MetricOption
) - > StopWatch

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

Parameters

NameTypeDescription
namestringThe name of the stopwatch, which will be sanitized for Prometheus metric naming conventions.
descriptionstringA descriptive string for the stopwatch, providing context for its purpose.
scaletime.DurationThe time unit scale for the stopwatch, determining how durations are measured (e.g., seconds, milliseconds).
scopepromutils.ScopeThe Prometheus scope to which this stopwatch will be registered, managing its lifecycle and exposure.
opts...MetricOptionOptional configurations for the stopwatch, such as emitting an unlabeled metric or adding additional labels. These options modify how the stopwatch is created and behaves.

Returns

TypeDescription
StopWatchA new StopWatch instance configured with the specified name, description, scale, and labels.