-
Notifications
You must be signed in to change notification settings - Fork 8
/
falcon_test.go
52 lines (44 loc) · 1.05 KB
/
falcon_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package falconmetrics
import (
"fmt"
"testing"
"time"
metrics "github.com/rcrowley/go-metrics"
)
func TestRegistry(t *testing.T) {
c := metrics.NewCounter()
metrics.Register("counter_name", c)
c.Inc(47)
g := metrics.NewGauge()
err := metrics.Register("gauge_name", g)
if err != nil {
fmt.Printf("Register Gauge %v\n", err)
return
}
g.Update(47)
s := metrics.NewExpDecaySample(1028, 0.015) // or metrics.NewUniformSample(1028)
h := metrics.NewHistogram(s)
metrics.Register("histogram_name", h)
h.Update(47)
for i := 0; i < 100; i++ {
h.Update(int64(i))
}
m := metrics.NewMeter()
metrics.Register("meter_name", m)
m.Mark(47)
for i := 0; i < 10; i++ {
m.Mark(int64(1))
time.Sleep(time.Millisecond * 1)
}
timer := metrics.NewTimer()
metrics.Register("timer_name", t)
timer.Time(func() { time.Sleep(time.Millisecond * 10) })
timer.Update(47)
//report to open falcon
cfg := DefaultFalconConfig
cfg.Debug = true
//report for each 5 seconds
cfg.Step = 5
falcon := NewFalcon(&cfg)
falcon.ReportRegistry(metrics.DefaultRegistry)
}