7 "github.com/go-kit/kit/metrics"
10 func TestMultiCounter(t *testing.T) {
14 mc := NewCounter(c1, c2, c3)
20 for i, m := range []fmt.Stringer{c1, c2, c3} {
21 if have := m.String(); want != have {
22 t.Errorf("c%d: want %q, have %q", i+1, want, have)
27 func TestMultiGauge(t *testing.T) {
31 mg := NewGauge(g1, g2, g3)
39 for i, m := range []fmt.Stringer{g1, g2, g3} {
40 if have := m.String(); want != have {
41 t.Errorf("g%d: want %q, have %q", i+1, want, have)
46 func TestMultiHistogram(t *testing.T) {
47 h1 := &mockHistogram{}
48 h2 := &mockHistogram{}
49 h3 := &mockHistogram{}
50 mh := NewHistogram(h1, h2, h3)
58 for i, m := range []fmt.Stringer{h1, h2, h3} {
59 if have := m.String(); want != have {
60 t.Errorf("g%d: want %q, have %q", i+1, want, have)
65 type mockCounter struct {
69 func (c *mockCounter) Add(delta float64) { c.obs = append(c.obs, delta) }
70 func (c *mockCounter) With(...string) metrics.Counter { return c }
71 func (c *mockCounter) String() string { return fmt.Sprintf("%v", c.obs) }
73 type mockGauge struct {
77 func (g *mockGauge) Set(value float64) { g.obs = append(g.obs, value) }
78 func (g *mockGauge) With(...string) metrics.Gauge { return g }
79 func (g *mockGauge) String() string { return fmt.Sprintf("%v", g.obs) }
80 func (g *mockGauge) Add(delta float64) {
83 value = g.obs[len(g.obs)-1] + delta
87 g.obs = append(g.obs, value)
90 type mockHistogram struct {
94 func (h *mockHistogram) Observe(value float64) { h.obs = append(h.obs, value) }
95 func (h *mockHistogram) With(...string) metrics.Histogram { return h }
96 func (h *mockHistogram) String() string { return fmt.Sprintf("%v", h.obs) }