-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics_test.go
35 lines (30 loc) · 1.05 KB
/
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
33
34
35
package waf_test
import (
"testing"
"gitlab.com/tozd/waf"
)
func TestMetrics(t *testing.T) {
t.Parallel()
metrics := (*waf.Metrics)(nil)
// There is a similar set of calls in TestMetricsMiddleware.
metrics.Counter("counter").Add(40)
metrics.Counter("discardedCounter").Inc().Discard()
metrics.Duration("duration").Start().Stop()
metrics.Duration("foreverDuration").Start()
metrics.Duration("discardedDuration1").Start().Discard().Stop()
metrics.Duration("discardedDuration2").Start().Stop().Discard()
ds := metrics.Durations("durations")
ds.Start().Stop()
ds.Start().Stop()
ds = metrics.Durations("discardedDurations")
ds.Start().Discard().Stop()
ds.Start().Stop().Discard()
dc := metrics.DurationCounter("dc").Start().Add(43)
metrics.DurationCounter("discardedDc1").Start().Add(32).Discard().Stop()
metrics.DurationCounter("discardedDc2").Start().Add(33).Stop().Discard()
metrics.DurationCounter("foreverDc").Start().Add(43)
metrics.Counter("counter").Inc()
metrics.DurationCounter("dc").Inc()
metrics.Duration("trailer").Start().Stop()
dc.Stop()
}