-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics_test.go
32 lines (25 loc) · 927 Bytes
/
metrics_test.go
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
package servicefoundation_test
import (
"testing"
"time"
sf "github.com/Travix-International/go-servicefoundation"
"github.com/stretchr/testify/assert"
)
func TestMetricsImpl(t *testing.T) {
logger := mockLogger{}
sut := sf.NewMetrics("testcount", &logger)
// Act
sut.Count("sub", "count", "help")
sut.IncreaseCounter("sub", "inc", "help", 5)
sut.CountLabels("", "lbl", "help", []string{"a", "b", "c"}, []string{"1", "2", "3"})
sut.SetGauge(float64(55), "sub", "gauge", "help")
h := sut.AddHistogramVec("sub", "hist", "help", []string{"a", "b", "c"}, []string{"1", "2", "3"})
h.RecordTimeElapsed(time.Now())
h.RecordDuration(time.Now(), time.Microsecond)
s := sut.AddSummaryVec("sub", "sum", "help", []string{"a", "b", "c"}, []string{"1", "2", "3"})
s.RecordTimeElapsed(time.Now())
s.RecordDuration(time.Now(), time.Millisecond)
assert.NotNil(t, h)
assert.NotNil(t, s)
logger.AssertExpectations(t)
}