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, each with a distinct set of label 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. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 will distinguish the elements of the 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 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](summaryoptions.md?sid=flytestdlib_promutils_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](summaryoptions.md?sid=flytestdlib_promutils_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](summaryoptions.md?sid=flytestdlib_promutils_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](summaryoptions.md?sid=flytestdlib_promutils_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, each with a distinct set of label 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. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 will distinguish the elements of the 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.
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, each with a distinct set of label 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. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 will distinguish the elements of the vector. |
Returns
| Type | Description |
|---|
*prometheus.HistogramVec | A Prometheus HistogramVec metric. |
NewHistogramVecWithOptions()
@classmethod
def NewHistogramVecWithOptions(
name: string,
description: string,
options: [HistogramOptions](histogramoptions.md?sid=flytestdlib_promutils_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.
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](histogramoptions.md?sid=flytestdlib_promutils_histogramoptions) | Custom options for the Histogram metric, such as bucket definitions. |
| labelNames | string | A list of label names that will distinguish the elements of the 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](histogramoptions.md?sid=flytestdlib_promutils_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. 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](histogramoptions.md?sid=flytestdlib_promutils_histogramoptions) | Custom options for the Histogram metric, such as bucket definitions. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 represents a single numerical value that only ever goes up.
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. 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. 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, each with a distinct set of label 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. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 will distinguish the elements of the 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.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the StopWatch metric. The metric name will be auto-suffixed with the appropriate scale. |
| description | string | A brief explanation of the StopWatch's purpose. |
| scale | time.Duration | The scale of the timer (e.g., time.Millisecond for milliseconds). Refer to https://golang.org/pkg/time/#Duration for more information. |
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 name of the StopWatch metric. The metric name will be auto-suffixed with the appropriate scale. |
| description | string | A brief explanation of the StopWatch's purpose. |
| scale | time.Duration | The scale of the timer (e.g., time.Millisecond for milliseconds). Refer to https://golang.org/pkg/time/#Duration for more information. |
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.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the StopWatchVec metric. The metric name will be auto-suffixed with the appropriate scale. |
| description | string | A brief explanation of the StopWatchVec's purpose. |
| scale | time.Duration | The scale of the timer (e.g., time.Millisecond for milliseconds). Refer to https://golang.org/pkg/time/#Duration for more information. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 name of the StopWatchVec metric. The metric name will be auto-suffixed with the appropriate scale. |
| description | string | A brief explanation of the StopWatchVec's purpose. |
| scale | time.Duration | The scale of the timer (e.g., time.Millisecond for milliseconds). Refer to https://golang.org/pkg/time/#Duration for more information. |
| labelNames | string | A list of label names that will distinguish the elements of the vector. |
Returns
| Type | Description |
|---|
*StopWatchVec | A StopWatchVec object. |
NewHistogramStopWatch()
@classmethod
def NewHistogramStopWatch(
name: string,
description: string
) - > ([HistogramStopWatch](labeled/histogramstopwatch.md?sid=flytestdlib_promutils_labeled_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.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the HistogramStopWatch metric. |
| description | string | A brief explanation of the HistogramStopWatch's purpose. Scale is assumed to be seconds with buckets spanning 0.005s to 10s. |
Returns
| Type | Description |
|---|
([HistogramStopWatch](labeled/histogramstopwatch.md?sid=flytestdlib_promutils_labeled_histogramstopwatch), error) | A HistogramStopWatch object and an error if creation fails. |
MustNewHistogramStopWatch()
@classmethod
def MustNewHistogramStopWatch(
name: string,
description: string
) - > [HistogramStopWatch](labeled/histogramstopwatch.md?sid=flytestdlib_promutils_labeled_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 name of the HistogramStopWatch metric. |
| description | string | A brief explanation of the HistogramStopWatch's purpose. Scale is assumed to be seconds with buckets spanning 0.005s to 10s. |
Returns
| Type | Description |
|---|
[HistogramStopWatch](labeled/histogramstopwatch.md?sid=flytestdlib_promutils_labeled_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 that can be aggregated across instances, with quantiles computed server-side.
Parameters
| Name | Type | Description |
|---|
| name | string | The name of the HistogramStopWatchVec metric. |
| description | string | A brief explanation of the HistogramStopWatchVec's purpose. Scale is assumed to be seconds with buckets spanning 0.005s to 10s. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 name of the HistogramStopWatchVec metric. |
| description | string | A brief explanation of the HistogramStopWatchVec's purpose. Scale is assumed to be seconds with buckets spanning 0.005s to 10s. |
| labelNames | string | A list of label names that will distinguish the elements of the 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 prefixes. 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 instance representing the sub-scope. |
CurrentScope()
@classmethod
def CurrentScope() - > string
Retrieves the name of the current scope. This can be used when manually creating metrics to ensure they adhere to the current prefix.
Returns
| Type | Description |
|---|
string | The name of the current scope. |
NewScopedMetricName()
@classmethod
def NewScopedMetricName(
name: string
) - > string
Generates a metric name prefixed with the current scope. This is useful for directly creating metrics while maintaining the scope's naming convention.
Parameters
| Name | Type | Description |
|---|
| name | string | The base name of the metric. |
Returns
| Type | Description |
|---|
string | A string representing the metric name with the current scope prefix. |