2018-05-01 23:45:06 +00:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2021-03-23 14:30:43 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
2018-05-01 23:45:06 +00:00
|
|
|
|
2021-03-23 14:30:43 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2018-05-01 23:45:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestEnd(t *testing.T) {
|
2021-03-23 14:30:43 +00:00
|
|
|
m := prometheus.NewHistogramVec(
|
|
|
|
prometheus.HistogramOpts{
|
|
|
|
Namespace: "TestCallLatencyWithoutMeasurement",
|
|
|
|
Name: "Latency",
|
|
|
|
Buckets: prometheus.LinearBuckets(0, 50, 100),
|
|
|
|
},
|
|
|
|
[]string{"key"},
|
|
|
|
)
|
|
|
|
timer := NewTimer(m, time.Millisecond, "key")
|
|
|
|
assert.Equal(t, time.Duration(0), timer.End("dne"))
|
|
|
|
timer.Start("test")
|
|
|
|
assert.NotEqual(t, time.Duration(0), timer.End("test"))
|
2018-05-01 23:45:06 +00:00
|
|
|
}
|