package svc import ( "code.30cm.net/digimon/app-cloudep-notification-service/internal/config" "context" "fmt" "os" "github.com/grafana/pyroscope-go" "github.com/zeromicro/go-zero/core/logx" ) func InitPyroScope(c config.Config) { if c.PyroScope.Enable { podName := os.Getenv("POD_NAME") _, err := pyroscope.Start(pyroscope.Config{ ApplicationName: fmt.Sprintf("biz-%s-%s", c.Name, podName), ServerAddress: c.PyroScope.URL, Logger: logx.WithContext(context.Background()), ProfileTypes: []pyroscope.ProfileType{ pyroscope.ProfileCPU, pyroscope.ProfileInuseObjects, pyroscope.ProfileAllocObjects, pyroscope.ProfileInuseSpace, pyroscope.ProfileAllocSpace, pyroscope.ProfileGoroutines, pyroscope.ProfileMutexCount, pyroscope.ProfileMutexDuration, pyroscope.ProfileBlockCount, pyroscope.ProfileBlockDuration, }, }) if err != nil { logx.WithCallerSkip(1).WithFields(logx.LogField{ Key: "error", Value: err.Error(), }).Error("failed to init pyroscope") panic(fmt.Sprintf("Pyroscope start err: %s", err.Error())) } } }