14 | 14 |
)
|
15 | 15 |
|
16 | 16 |
func TestCounter(t *testing.T) {
|
17 | |
counter := generic.NewCounter("my_counter").With("label", "counter").(*generic.Counter)
|
|
17 |
name := "my_counter"
|
|
18 |
counter := generic.NewCounter(name).With("label", "counter").(*generic.Counter)
|
|
19 |
if want, have := name, counter.Name; want != have {
|
|
20 |
t.Errorf("Name: want %q, have %q", want, have)
|
|
21 |
}
|
18 | 22 |
value := func() float64 { return counter.Value() }
|
19 | 23 |
if err := teststat.TestCounter(counter, value); err != nil {
|
20 | 24 |
t.Fatal(err)
|
|
35 | 39 |
}
|
36 | 40 |
|
37 | 41 |
func TestGauge(t *testing.T) {
|
38 | |
gauge := generic.NewGauge("my_gauge").With("label", "gauge").(*generic.Gauge)
|
|
42 |
name := "my_gauge"
|
|
43 |
gauge := generic.NewGauge(name).With("label", "gauge").(*generic.Gauge)
|
|
44 |
if want, have := name, gauge.Name; want != have {
|
|
45 |
t.Errorf("Name: want %q, have %q", want, have)
|
|
46 |
}
|
39 | 47 |
value := func() float64 { return gauge.Value() }
|
40 | 48 |
if err := teststat.TestGauge(gauge, value); err != nil {
|
41 | 49 |
t.Fatal(err)
|
|
43 | 51 |
}
|
44 | 52 |
|
45 | 53 |
func TestHistogram(t *testing.T) {
|
46 | |
histogram := generic.NewHistogram("my_histogram", 50).With("label", "histogram").(*generic.Histogram)
|
|
54 |
name := "my_histogram"
|
|
55 |
histogram := generic.NewHistogram(name, 50).With("label", "histogram").(*generic.Histogram)
|
|
56 |
if want, have := name, histogram.Name; want != have {
|
|
57 |
t.Errorf("Name: want %q, have %q", want, have)
|
|
58 |
}
|
47 | 59 |
quantiles := func() (float64, float64, float64, float64) {
|
48 | 60 |
return histogram.Quantile(0.50), histogram.Quantile(0.90), histogram.Quantile(0.95), histogram.Quantile(0.99)
|
49 | 61 |
}
|