package promassert_test import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) const ( g1name = "my_test_gauge" gv1name = "my_test_gauge_vec" c1name = "my_test_counter" c1value = 42.0 cv1name = "my_test_counter_vec" cv1value1 = 1984.0 cv1value2 = 8.0 cv1value3 = 27.0 cv1value4 = 86.0 ) var ( cv1keys = []string{"foo", "bar", "baz"} cv1labels1 = map[string]string{"foo": "hello", "bar": "world", "baz": "bit"} cv1labels2 = map[string]string{"foo": "goodbye", "bar": "world", "baz": "bit"} cv1labels3 = map[string]string{"foo": "hello", "bar": "goodbye", "baz": "bit"} cv1labels4 = map[string]string{"foo": "dog", "bar": "cat", "baz": "frog"} ) // create the metrics in an init function so it only runs once per test. // this makes the --count=N flag work for N>1. func init() { const help = "help" // c1 is a nonvectorized counter c1 := promauto.NewCounter(prometheus.CounterOpts{ Name: c1name, Help: help, }) c1.Add(c1value) // g1 is a nonvectorized counter using the same values as c1 g1 := promauto.NewGauge(prometheus.GaugeOpts{ Name: g1name, Help: help, }) g1.Add(c1value) // cv1 is a vectorized counter cv1 := promauto.NewCounterVec(prometheus.CounterOpts{ Name: cv1name, Help: help, }, cv1keys) cv1.With(cv1labels1).Add(cv1value1) cv1.With(cv1labels2).Add(cv1value2) cv1.With(cv1labels3).Add(cv1value3) cv1.With(cv1labels4).Add(cv1value4) // gv1 is a vectorized counter using the same values as cv1 gv1 := promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: gv1name, Help: help, }, cv1keys) gv1.With(cv1labels1).Add(cv1value1) gv1.With(cv1labels2).Add(cv1value2) gv1.With(cv1labels3).Add(cv1value3) gv1.With(cv1labels4).Add(cv1value4) }