A Scope represents a prefix in Prometheus. It is nestable, thus every metric that is published does not need to provide a prefix, but just the name of the metric. As long as the Scope is used to create a new instance of the metric The prefix (or scope) is automatically set.
Methods
NewGauge()
@classmethod
def NewGauge(
name: string,
description: string
) - > (prometheus.Gauge, error)
Creates a new prometheus.Gauge metric with the current scope as its prefix. This metric represents a single numerical value that can arbitrarily go up and down.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
Returns
| Type | Description |
|---|
(prometheus.Gauge, error) | A Prometheus Gauge metric and an error if creation fails. |
MustNewGauge()
@classmethod
def MustNewGauge(
name: string,
description: string
) - > prometheus.Gauge
Creates a new prometheus.Gauge metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
Returns
| Type | Description |
|---|
prometheus.Gauge | A Prometheus Gauge metric. |
NewGaugeVec()
@classmethod
def NewGaugeVec(
name: string,
description: string,
labelNames: string
) - > (*prometheus.GaugeVec, error)
Creates a new prometheus.GaugeVec metric with the current scope as its prefix. This metric is a vector of Gauges, allowing the same metric to be broken down by different label dimensions.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
(*prometheus.GaugeVec, error) | A Prometheus GaugeVec metric and an error if creation fails. |
MustNewGaugeVec()
@classmethod
def MustNewGaugeVec(
name: string,
description: string,
labelNames: string
) - > *prometheus.GaugeVec
Creates a new prometheus.GaugeVec metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
*prometheus.GaugeVec | A Prometheus GaugeVec metric. |
NewSummary()
@classmethod
def NewSummary(
name: string,
description: string
) - > (prometheus.Summary, error)
Creates a new prometheus.Summary metric with the current scope as its prefix. This metric samples observations and calculates configurable quantiles over a sliding time window.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
Returns
| Type | Description |
|---|
(prometheus.Summary, error) | A Prometheus Summary metric and an error if creation fails. |
MustNewSummary()
@classmethod
def MustNewSummary(
name: string,
description: string
) - > prometheus.Summary
Creates a new prometheus.Summary metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
Returns
| Type | Description |
|---|
prometheus.Summary | A Prometheus Summary metric. |
NewSummaryWithOptions()
@classmethod
def NewSummaryWithOptions(
name: string,
description: string,
options: SummaryOptions
) - > (prometheus.Summary, error)
Creates a new prometheus.Summary metric with custom options, such as a custom set of objectives (i.e., target quantiles).
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| options | SummaryOptions | Custom options for the Summary metric, such as objectives for quantile calculation. |
Returns
| Type | Description |
|---|
(prometheus.Summary, error) | A Prometheus Summary metric and an error if creation fails. |
MustNewSummaryWithOptions()
@classmethod
def MustNewSummaryWithOptions(
name: string,
description: string,
options: SummaryOptions
) - > prometheus.Summary
Creates a new prometheus.Summary metric with custom options, such as a custom set of objectives (i.e., target quantiles). This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| options | SummaryOptions | Custom options for the Summary metric, such as objectives for quantile calculation. |
Returns
| Type | Description |
|---|
prometheus.Summary | A Prometheus Summary metric. |
NewSummaryVec()
@classmethod
def NewSummaryVec(
name: string,
description: string,
labelNames: string
) - > (*prometheus.SummaryVec, error)
Creates a new prometheus.SummaryVec metric with the current scope as its prefix. This metric is a vector of Summaries, allowing the same metric to be broken down by different label dimensions.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
(*prometheus.SummaryVec, error) | A Prometheus SummaryVec metric and an error if creation fails. |
MustNewSummaryVec()
@classmethod
def MustNewSummaryVec(
name: string,
description: string,
labelNames: string
) - > *prometheus.SummaryVec
Creates a new prometheus.SummaryVec metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
*prometheus.SummaryVec | A Prometheus SummaryVec metric. |
NewHistogram()
@classmethod
def NewHistogram(
name: string,
description: string
) - > (prometheus.Histogram, error)
Creates a new prometheus.Histogram metric with the current scope as its prefix. This metric samples observations and counts them into configurable buckets, providing a histogram of observed values.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
Returns
| Type | Description |
|---|
(prometheus.Histogram, error) | A Prometheus Histogram metric and an error if creation fails. |
MustNewHistogram()
@classmethod
def MustNewHistogram(
name: string,
description: string
) - > prometheus.Histogram
Creates a new prometheus.Histogram metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
Returns
| Type | Description |
|---|
prometheus.Histogram | A Prometheus Histogram metric. |
NewHistogramVec()
@classmethod
def NewHistogramVec(
name: string,
description: string,
labelNames: string
) - > (*prometheus.HistogramVec, error)
Creates a new prometheus.HistogramVec metric with the current scope as its prefix. This metric is a vector of Histograms, allowing the same metric to be broken down by different label dimensions.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
(*prometheus.HistogramVec, error) | A Prometheus HistogramVec metric and an error if creation fails. |
MustNewHistogramVec()
@classmethod
def MustNewHistogramVec(
name: string,
description: string,
labelNames: string
) - > *prometheus.HistogramVec
Creates a new prometheus.HistogramVec metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
*prometheus.HistogramVec | A Prometheus HistogramVec metric. |
NewHistogramVecWithOptions()
@classmethod
def NewHistogramVecWithOptions(
name: string,
description: string,
options: HistogramOptions,
labelNames: string
) - > (*prometheus.HistogramVec, error)
Creates a new prometheus.HistogramVec metric with the current scope as its prefix and a custom set of options, such as specific buckets for value distribution.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| options | HistogramOptions | Custom options for the Histogram metric, such as bucket definitions. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
(*prometheus.HistogramVec, error) | A Prometheus HistogramVec metric and an error if creation fails. |
MustNewHistogramVecWithOptions()
@classmethod
def MustNewHistogramVecWithOptions(
name: string,
description: string,
options: HistogramOptions,
labelNames: string
) - > *prometheus.HistogramVec
Creates a new prometheus.HistogramVec metric with the current scope as its prefix and a custom set of options, such as specific buckets for value distribution. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| options | HistogramOptions | Custom options for the Histogram metric, such as bucket definitions. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
*prometheus.HistogramVec | A Prometheus HistogramVec metric. |
NewCounter()
@classmethod
def NewCounter(
name: string,
description: string
) - > (prometheus.Counter, error)
Creates a new prometheus.Counter metric with the current scope as its prefix. This metric is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. Note that counters are ever-increasing and cumulative; use Summary/Histogram for bucketed observations. |
Returns
| Type | Description |
|---|
(prometheus.Counter, error) | A Prometheus Counter metric and an error if creation fails. |
MustNewCounter()
@classmethod
def MustNewCounter(
name: string,
description: string
) - > prometheus.Counter
Creates a new prometheus.Counter metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. Note that counters are ever-increasing and cumulative; use Summary/Histogram for bucketed observations. |
Returns
| Type | Description |
|---|
prometheus.Counter | A Prometheus Counter metric. |
NewCounterVec()
@classmethod
def NewCounterVec(
name: string,
description: string,
labelNames: string
) - > (*prometheus.CounterVec, error)
Creates a new prometheus.CounterVec metric with the current scope as its prefix. This metric is a vector of Counters, allowing the same metric to be broken down by different label dimensions.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
(*prometheus.CounterVec, error) | A Prometheus CounterVec metric and an error if creation fails. |
MustNewCounterVec()
@classmethod
def MustNewCounterVec(
name: string,
description: string,
labelNames: string
) - > *prometheus.CounterVec
Creates a new prometheus.CounterVec metric with the current scope as its prefix. This method panics if the metric cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the metric, following Prometheus conventions (mostly [_a-z]). |
| description | string | A brief explanation of the metric's purpose. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
*prometheus.CounterVec | A Prometheus CounterVec metric. |
NewStopWatch()
@classmethod
def NewStopWatch(
name: string,
description: string,
scale: time.Duration
) - > ([StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch), error)
Creates a new StopWatch object within the current Scope. This custom wrapper provides timing functionality, with the metric name automatically suffixed to indicate the specified time scale.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the StopWatch metric. |
| description | string | A brief explanation of what the StopWatch is measuring. |
| scale | time.Duration | The time unit for the StopWatch (e.g., time.Millisecond). The metric name will be auto-suffixed based on this scale. |
Returns
| Type | Description |
|---|
([StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch), error) | A StopWatch object and an error if creation fails. |
MustNewStopWatch()
@classmethod
def MustNewStopWatch(
name: string,
description: string,
scale: time.Duration
) - > [StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch)
Creates a new StopWatch object within the current Scope. This method panics if the StopWatch cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the StopWatch metric. |
| description | string | A brief explanation of what the StopWatch is measuring. |
| scale | time.Duration | The time unit for the StopWatch (e.g., time.Millisecond). The metric name will be auto-suffixed based on this scale. |
Returns
| Type | Description |
|---|
[StopWatch](labeled/stopwatch.md?sid=flytestdlib_promutils_labeled_stopwatch) | A StopWatch object. |
NewStopWatchVec()
@classmethod
def NewStopWatchVec(
name: string,
description: string,
scale: time.Duration,
labelNames: string
) - > (*StopWatchVec, error)
Creates a new StopWatchVec object within the current Scope. This custom wrapper provides timing functionality for a vector of StopWatches, with the metric name automatically suffixed to indicate the specified time scale.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the StopWatchVec metric. |
| description | string | A brief explanation of what the StopWatchVec is measuring. |
| scale | time.Duration | The time unit for the StopWatchVec (e.g., time.Millisecond). The metric name will be auto-suffixed based on this scale. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
(*StopWatchVec, error) | A StopWatchVec object and an error if creation fails. |
MustNewStopWatchVec()
@classmethod
def MustNewStopWatchVec(
name: string,
description: string,
scale: time.Duration,
labelNames: string
) - > *StopWatchVec
Creates a new StopWatchVec object within the current Scope. This method panics if the StopWatchVec cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the StopWatchVec metric. |
| description | string | A brief explanation of what the StopWatchVec is measuring. |
| scale | time.Duration | The time unit for the StopWatchVec (e.g., time.Millisecond). The metric name will be auto-suffixed based on this scale. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
*StopWatchVec | A StopWatchVec object. |
NewHistogramStopWatch()
@classmethod
def NewHistogramStopWatch(
name: string,
description: string
) - > (HistogramStopWatch, error)
Creates a new HistogramStopWatch object within the current Scope. This custom wrapper provides timing functionality that can be aggregated across instances, with quantiles computed server-side. The scale is assumed to be seconds with buckets spanning 0.005s to 10s.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the HistogramStopWatch metric. |
| description | string | A brief explanation of what the HistogramStopWatch is measuring. |
Returns
| Type | Description |
|---|
(HistogramStopWatch, error) | A HistogramStopWatch object and an error if creation fails. |
MustNewHistogramStopWatch()
@classmethod
def MustNewHistogramStopWatch(
name: string,
description: string
) - > HistogramStopWatch
Creates a new HistogramStopWatch object within the current Scope. This method panics if the HistogramStopWatch cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the HistogramStopWatch metric. |
| description | string | A brief explanation of what the HistogramStopWatch is measuring. |
Returns
| Type | Description |
|---|
HistogramStopWatch | A HistogramStopWatch object. |
NewHistogramStopWatchVec()
@classmethod
def NewHistogramStopWatchVec(
name: string,
description: string,
labelNames: string
) - > (*HistogramStopWatchVec, error)
Creates a new HistogramStopWatchVec object within the current Scope. This custom wrapper provides timing functionality for a vector of HistogramStopWatches, allowing aggregation across instances with server-side quantile computation. The scale is assumed to be seconds with buckets spanning 0.005s to 10s.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the HistogramStopWatchVec metric. |
| description | string | A brief explanation of what the HistogramStopWatchVec is measuring. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
(*HistogramStopWatchVec, error) | A HistogramStopWatchVec object and an error if creation fails. |
MustNewHistogramStopWatchVec()
@classmethod
def MustNewHistogramStopWatchVec(
name: string,
description: string,
labelNames: string
) - > *HistogramStopWatchVec
Creates a new HistogramStopWatchVec object within the current Scope. This method panics if the HistogramStopWatchVec cannot be created.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the HistogramStopWatchVec metric. |
| description | string | A brief explanation of what the HistogramStopWatchVec is measuring. |
| labelNames | string | A list of label names that differentiate the elements of the metric vector. |
Returns
| Type | Description |
|---|
*HistogramStopWatchVec | A HistogramStopWatchVec object. |
NewSubScope()
@classmethod
def NewSubScope(
name: string
) - > [Scope](scope.md?sid=flytestdlib_promutils_scope)
Creates a new sub-scope, allowing for nested metric naming. This is useful for organizing metrics hierarchically.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the sub-scope to create. |
Returns
| Type | Description |
|---|
[Scope](scope.md?sid=flytestdlib_promutils_scope) | A new Scope object representing the sub-scope. |
CurrentScope()
@classmethod
def CurrentScope() - > string
Returns the name of the current scope. This can be used when manually constructing metric names.
Returns
| Type | Description |
|---|
string | The name of the current scope. |
NewScopedMetricName()
@classmethod
def NewScopedMetricName(
name: string
) - > string
Provides a metric name prefixed with the current scope. This is useful for directly creating custom metrics that adhere to the current scoping convention.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the metric. |
Returns
| Type | Description |
|---|
string | A string representing the metric name prefixed with the current scope. |