forked from DataDog/datadog-process-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprom_gauge.go
More file actions
45 lines (36 loc) · 1.26 KB
/
prom_gauge.go
File metadata and controls
45 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-2020 Datadog, Inc.
package telemetry
import (
"github.com/prometheus/client_golang/prometheus"
)
// Gauge implementation using Prometheus.
type promGauge struct {
pg *prometheus.GaugeVec
}
// Set stores the value for the given tags.
func (g *promGauge) Set(value float64, tagsValue ...string) {
g.pg.WithLabelValues(tagsValue...).Set(value)
}
// Inc increments the Gauge value.
func (g *promGauge) Inc(tagsValue ...string) {
g.pg.WithLabelValues(tagsValue...).Inc()
}
// Dec decrements the Gauge value.
func (g *promGauge) Dec(tagsValue ...string) {
g.pg.WithLabelValues(tagsValue...).Dec()
}
// Delete deletes the value for the Gauge with the given tags.
func (g *promGauge) Delete(tagsValue ...string) {
g.pg.DeleteLabelValues(tagsValue...)
}
// Add adds the value to the Gauge value.
func (g *promGauge) Add(value float64, tagsValue ...string) {
g.pg.WithLabelValues(tagsValue...).Add(value)
}
// Sub subtracts the value to the Gauge value.
func (g *promGauge) Sub(value float64, tagsValue ...string) {
g.pg.WithLabelValues(tagsValue...).Sub(value)
}