Skip to content

Instantly share code, notes, and snippets.

@browny
Created April 13, 2016 06:42
Show Gist options
  • Select an option

  • Save browny/36fd2cbe1c0921e449822d1fb871ca31 to your computer and use it in GitHub Desktop.

Select an option

Save browny/36fd2cbe1c0921e449822d1fb871ca31 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
"github.com/csigo/metric"
)
var (
ctr = metric.NewClient("revealer", "")
)
func main() {
testFunc := func() {
defer ctr.BumpTime("aaa.bbb.ccc.proc_time").End()
time.Sleep(3 * time.Second)
ctr.BumpSum("aaa.bbb.ccc", 1)
}
go func() {
for {
testFunc()
}
}()
/// ------------------------------------------------
for {
time.Sleep(time.Minute)
for _, s := range metric.GetSnapshot("*", "*") {
bs := s.SliceIn(time.Minute)
if len(bs) == 0 {
continue
}
b := bs[len(bs)-1]
// export
fmt.Println(s.Pkg(), s.Name(), b.Sum, b.Avg)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment