Skip to main content

StopWatchVec

This class represents a simple StopWatch that integrates with Prometheus Summary metrics. It automatically scales the output to match a specified time unit (e.g., milliseconds, seconds). Users should obtain instances of this StopWatch via a Scope rather than direct instantiation.

Methods


WithLabelValues()

@classmethod
def WithLabelValues(
values: string
) - > [StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch)

Retrieves a StopWatch instance with the specified label values. This method allows you to associate specific labels with the StopWatch for metric tracking.

Parameters

NameTypeDescription
valuesstringThe label values to associate with the StopWatch instance. These values correspond to the labels defined in the underlying Prometheus SummaryVec.

Returns

TypeDescription
[StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch)A StopWatch instance configured with the provided label values.

GetMetricWith()

@classmethod
def GetMetricWith(
labels: prometheus.Labels
) - > ([StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch), error)

Fetches a StopWatch instance associated with the given Prometheus labels. This method is used to retrieve a specific StopWatch for recording metrics based on a set of predefined labels.

Parameters

NameTypeDescription
labelsprometheus.LabelsA map of Prometheus labels (key-value pairs) used to identify and retrieve the correct StopWatch instance.

Returns

TypeDescription
([StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch), error)A tuple containing the StopWatch instance and an error if the retrieval fails.