-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathpyro.go
41 lines (36 loc) · 873 Bytes
/
pyro.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
package main
import (
"fmt"
"github.com/grafana/pyroscope-go"
"log"
"os"
)
func initPyro() {
// Pyroscope configuration
serverAddress := os.Getenv("PYROSCOPE_SERVER_ADDRESS")
if serverAddress == "" {
return
}
applicationName := os.Getenv("PYROSCOPE_APPLICATION_NAME")
if applicationName == "" {
applicationName = "gigapipe"
}
// Initialize Pyroscope
config := pyroscope.Config{
ApplicationName: applicationName,
ServerAddress: serverAddress,
Logger: pyroscope.StandardLogger,
ProfileTypes: []pyroscope.ProfileType{
pyroscope.ProfileCPU,
pyroscope.ProfileAllocObjects,
pyroscope.ProfileAllocSpace,
pyroscope.ProfileInuseObjects,
pyroscope.ProfileInuseSpace,
},
}
_, err := pyroscope.Start(config)
if err != nil {
log.Fatalf("Failed to start Pyroscope: %v", err)
}
fmt.Println("Pyroscope profiling started")
}