11package main
22
33import (
4+ "fmt"
45 "github.com/One-com/gone/metric"
56 "github.com/One-com/gone/metric/sink/statsd"
6- "fmt"
77
88 "log"
99 "time"
10- // "strconv"
10+ // "strconv"
1111 "io"
1212 "os"
1313 "sync"
1414)
1515
1616type blockOut struct {
17- mu sync.Mutex
17+ mu sync.Mutex
1818 out io.Writer
1919}
2020
@@ -26,44 +26,43 @@ func (b *blockOut) Write(p []byte) (n int, err error) {
2626 return
2727}
2828
29- var period = metric .FlushInterval (2 * time .Second )
29+ var period = metric .FlushInterval (2 * time .Second )
3030
3131func main () {
3232
3333 sink , err := statsd .New (
3434 statsd .Buffer (512 ),
35- statsd .Output (& blockOut {out :os .Stdout }),
35+ statsd .Output (& blockOut {out : os .Stdout }),
3636 statsd .Prefix ("prefix" ))
3737 if err != nil {
3838 log .Fatal (err )
3939 }
4040
41- // client.Gauge("gauge", 42, false)
42- // client.Counter("c", 1, true)
41+ // client.Gauge("gauge", 42, false)
42+ // client.Counter("c", 1, true)
4343
44-
4544 client := metric .NewClient (sink , period )
4645
47- gauge := client .NewGauge ("gauge" ,period )
48- timer := client .NewTimer ("timer" , period )
49- histo := client .NewHistogram ("histo" ,period )
50- counter := client .NewCounter ("counter" ,period )
51- // set := client.NewSet("set", period)
46+ gauge := client .NewGauge ("gauge" , period )
47+ timer := client .NewTimer ("timer" , period )
48+ histo := client .NewHistogram ("histo" , period )
49+ counter := client .NewCounter ("counter" , period )
50+ // set := client.NewSet("set", period)
5251
5352 g := 100
5453 for g != 0 {
55- client .Gauge (fmt .Sprintf ("g%d" ,g ), uint64 (g ), false )
56- client .Counter (fmt .Sprintf ("c%d" ,g ), 1 , false )
54+ client .Gauge (fmt .Sprintf ("g%d" , g ), uint64 (g ), false )
55+ client .Counter (fmt .Sprintf ("c%d" , g ), 1 , false )
5756 counter .Inc (1 )
5857 gauge .Set (uint64 (g ))
59- timer .Sample (time .Duration (g )* time .Millisecond )
58+ timer .Sample (time .Duration (g ) * time .Millisecond )
6059 histo .Sample (int64 (g ))
61- // set.Update(strconv.FormatInt(int64(g), 10))
62-
60+ // set.Update(strconv.FormatInt(int64(g), 10))
61+
6362 time .Sleep (time .Second )
6463 g --
65- if g % 2 == 0 {
66- if g % 4 == 0 {
64+ if g % 2 == 0 {
65+ if g % 4 == 0 {
6766 client .SetOptions (metric .FlushInterval (time .Second ))
6867 } else {
6968 client .SetOptions (metric .FlushInterval (0 ))
@@ -74,5 +73,3 @@ func main() {
7473
7574 client .Flush ()
7675}
77-
78-
0 commit comments