...
1 package promassert_test
2
3 import (
4 "github.com/prometheus/client_golang/prometheus"
5 "github.com/prometheus/client_golang/prometheus/promauto"
6 )
7
8 const (
9 g1name = "my_test_gauge"
10 gv1name = "my_test_gauge_vec"
11
12 c1name = "my_test_counter"
13 c1value = 42.0
14
15 cv1name = "my_test_counter_vec"
16 cv1value1 = 1984.0
17 cv1value2 = 8.0
18 cv1value3 = 27.0
19 cv1value4 = 86.0
20 )
21
22 var (
23 cv1keys = []string{"foo", "bar", "baz"}
24 cv1labels1 = map[string]string{"foo": "hello", "bar": "world", "baz": "bit"}
25 cv1labels2 = map[string]string{"foo": "goodbye", "bar": "world", "baz": "bit"}
26 cv1labels3 = map[string]string{"foo": "hello", "bar": "goodbye", "baz": "bit"}
27 cv1labels4 = map[string]string{"foo": "dog", "bar": "cat", "baz": "frog"}
28 )
29
30
31
32 func init() {
33 const help = "help"
34
35
36 c1 := promauto.NewCounter(prometheus.CounterOpts{
37 Name: c1name,
38 Help: help,
39 })
40 c1.Add(c1value)
41
42
43 g1 := promauto.NewGauge(prometheus.GaugeOpts{
44 Name: g1name,
45 Help: help,
46 })
47 g1.Add(c1value)
48
49
50 cv1 := promauto.NewCounterVec(prometheus.CounterOpts{
51 Name: cv1name,
52 Help: help,
53 }, cv1keys)
54 cv1.With(cv1labels1).Add(cv1value1)
55 cv1.With(cv1labels2).Add(cv1value2)
56 cv1.With(cv1labels3).Add(cv1value3)
57 cv1.With(cv1labels4).Add(cv1value4)
58
59
60 gv1 := promauto.NewGaugeVec(prometheus.GaugeOpts{
61 Name: gv1name,
62 Help: help,
63 }, cv1keys)
64 gv1.With(cv1labels1).Add(cv1value1)
65 gv1.With(cv1labels2).Add(cv1value2)
66 gv1.With(cv1labels3).Add(cv1value3)
67 gv1.With(cv1labels4).Add(cv1value4)
68 }
69
View as plain text