-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer_test.go
More file actions
34 lines (27 loc) · 856 Bytes
/
timer_test.go
File metadata and controls
34 lines (27 loc) · 856 Bytes
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
package stats
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTimerVector(t *testing.T) {
c := NewStaticCollector()
tv := NewTimerVector(RootScope(c), "example", []string{"foo", "bar"})
tv.WithLabels("foo", "bar").Start().Stop()
tv.WithLabels("biz", "biz").Start().Stop()
tv.WithLabels("foo", "bar").Start().Stop()
assert.Len(t, c.Get().Histograms, 2)
assert.Equal(t, "example_seconds", c.Get().Histograms[1].Name)
assert.Equal(t, int64(1), c.Get().Histograms[1].Value.Count)
assert.Equal(
t,
map[string]string{"bar": "biz", "foo": "biz"},
c.Get().Histograms[1].Value.Tags,
)
assert.Equal(t, "example_seconds", c.Get().Histograms[0].Name)
assert.Equal(t, int64(2), c.Get().Histograms[0].Value.Count)
assert.Equal(
t,
map[string]string{"bar": "bar", "foo": "foo"},
c.Get().Histograms[0].Value.Tags,
)
}