MCPcopy
hub / github.com/grafana/tempo / TestCounter

Function TestCounter

pkg/usagestats/stats_test.go:120–135  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestCounter(t *testing.T) {
121 synctest.Test(t, func(t *testing.T) {
122 c := NewCounter("test_counter")
123 c.Inc(100)
124 c.Inc(200)
125 c.Inc(300)
126 time.Sleep(1 * time.Second)
127 c.updateRate()
128 v := c.Value()
129 require.Equal(t, int64(600), v["total"])
130 require.GreaterOrEqual(t, v["rate"], float64(590))
131 c.reset()
132 require.Equal(t, int64(0), c.Value()["total"])
133 require.Equal(t, float64(0), c.Value()["rate"])
134 })
135}
136
137func TestStatistic(t *testing.T) {
138 s := NewStatistics("test_stats")

Callers

nothing calls this directly

Calls 8

IncMethod · 0.95
updateRateMethod · 0.95
ValueMethod · 0.95
resetMethod · 0.95
NewCounterFunction · 0.85
TestMethod · 0.80
SleepMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected