-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
56 lines (43 loc) · 956 Bytes
/
main.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
53
54
55
56
package main
import (
"math/rand"
"os"
"time"
"github.com/smallnest/zhuge"
"github.com/smallnest/zhuge/examples/btree"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func main() {
go initPyroscope()
tick := time.NewTicker(10 * time.Second)
for range tick.C {
btree.Run(16)
}
}
func initPyroscope() {
sc := zhuge.Config{
ApplicationName: "zhuge.test_client",
ServerAddress: "http://rpcx.io:4040",
Tags: map[string]string{"host": "192.168.3.1"},
Logger: zhuge.StandardLogger,
AuthToken: os.Getenv("PYROSCOPE_AUTH_TOKEN"),
ProfileTypes: []zhuge.ProfileType{
zhuge.ProfileCPU,
zhuge.ProfileAllocObjects,
zhuge.ProfileAllocSpace,
zhuge.ProfileInuseObjects,
zhuge.ProfileInuseSpace,
},
}
profiler, err := zhuge.NewSampleProfiler(sc)
if err != nil {
panic(err)
}
for {
go profiler.SampleNow()
d := time.Duration(rand.Intn(10)+10) * time.Second
time.Sleep(time.Duration(d))
}
}