Documentation ¶
Index ¶
- Variables
- func GetUniqueLabels(metricStringKeys []string, additionalLabels []string) []string
- func GetUnlabeledMetricName(metricName string) string
- func SetMetricKeys(keys ...contextutils.Key)
- func UnsetMetricKeys()
- type AdditionalLabelsOption
- type Counter
- type EmitUnlabeledMetricOption
- type Gauge
- type MetricOption
- type StopWatch
- type Summary
- type Timer
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadySet = fmt.Errorf("cannot set metric keys more than once") ErrEmpty = fmt.Errorf("cannot set metric keys to an empty set") ErrNeverSet = fmt.Errorf("must call SetMetricKeys prior to using labeled package") )
var EmitUnlabeledMetric = EmitUnlabeledMetricOption{}
Functions ¶
func GetUniqueLabels ¶ added in v0.4.19
GetUniqueLabels Remove labels from additionalLabels that already exist in metricStringKeys
func GetUnlabeledMetricName ¶
func SetMetricKeys ¶
func SetMetricKeys(keys ...contextutils.Key)
Sets keys to use with labeled metrics. The values of these keys will be pulled from context at runtime.
func UnsetMetricKeys ¶ added in v0.2.11
func UnsetMetricKeys()
Warning: This function is not thread safe and should be used for testing only outside of this package.
Types ¶
type AdditionalLabelsOption ¶ added in v0.3.12
type AdditionalLabelsOption struct { // A collection of labels to look for in the passed context. Labels []string }
AdditionalLabelsOption instructs the labeled metric to expect additional labels scoped for this just this metric in the context passed.
type Counter ¶
type Counter struct { *prometheus.CounterVec prometheus.Counter // contains filtered or unexported fields }
Counter represents a counter labeled with values from the context. See labeled.SetMetricsKeys for information about to configure that.
func NewCounter ¶
func NewCounter(name, description string, scope promutils.Scope, opts ...MetricOption) Counter
NewCounter creates a new labeled counter. Label keys must be set before instantiating a counter. See labeled.SetMetricsKeys for information about to configure that.
type EmitUnlabeledMetricOption ¶
type EmitUnlabeledMetricOption struct { }
Instructs the metric to emit unlabeled metric (besides the labeled one). This is useful to get overall system performance.
type Gauge ¶ added in v0.3.12
type Gauge struct { *prometheus.GaugeVec prometheus.Gauge // contains filtered or unexported fields }
Gauge represents a gauge labeled with values from the context. See labeled.SetMetricsKeys for more information
func NewGauge ¶ added in v0.3.12
func NewGauge(name, description string, scope promutils.Scope, opts ...MetricOption) Gauge
NewGauge creates a new labeled gauge. Label keys must be set before instantiating. If the unlabeled option is given, this object will also instantiate and emit another gauge with the given name with an _unlabeled suffix. See labeled.SetMetricsKeys for information about how to configure that.
func (Gauge) Add ¶ added in v0.3.12
Add adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.) The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about how to configure that.
func (Gauge) Dec ¶ added in v0.3.12
Dec decrements the level by 1. Use Sub to decrement by arbitrary values. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about how to configure that.
func (Gauge) Inc ¶ added in v0.3.12
Inc increments the gauge by 1. Use Add to increment by arbitrary values. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about how to configure that.
func (Gauge) Set ¶ added in v0.3.12
Set sets the Gauge to an arbitrary value. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about how to configure that.
func (Gauge) SetToCurrentTime ¶ added in v0.3.12
SetToCurrentTime sets the Gauge to the current Unix time in seconds.
type MetricOption ¶
type MetricOption interface {
// contains filtered or unexported methods
}
Defines extra set of options to customize the emitted metric.
type StopWatch ¶
type StopWatch struct { *promutils.StopWatchVec // We use SummaryVec for emitting StopWatchVec, this computes percentiles per metric tags combination on the client- // side. This makes it impossible to aggregate percentiles across tags (e.g. to have system-wide view). When enabled // through a flag in the constructor, we initialize this additional untagged stopwatch to compute percentiles // across tags. promutils.StopWatch // contains filtered or unexported fields }
func NewStopWatch ¶
func NewStopWatch(name, 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.
func (StopWatch) Observe ¶
Observe observes specified duration between the start and end time. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about how to configure that.
func (StopWatch) Start ¶
Start creates a new Instance of the StopWatch called a Timer that is closeable/stoppable. Common pattern to time a scope would be
{ timer := stopWatch.Start(ctx) defer timer.Stop() .... }
type Summary ¶ added in v0.4.10
type Summary struct { *prometheus.SummaryVec prometheus.Summary // contains filtered or unexported fields }
Summary represents a summary labeled with values from the context. See labeled.SetMetricsKeys for information about how to configure that.
func NewSummary ¶ added in v0.4.10
func NewSummary(name, description string, scope promutils.Scope, opts ...MetricOption) Summary
NewSummary creates a new labeled summary. Label keys must be set before instantiating. If the unlabeled option is given, this object will also instantiate and emit another summary with the given name with an _unlabeled suffix. See labeled.SetMetricsKeys for information about how to configure that.