fork of https://github.com/sourcegraph/zoekt
1package profiler
2
3import (
4 "log"
5 "os"
6
7 "cloud.google.com/go/profiler"
8)
9
10// Init starts the supported profilers IFF the environment variable is set.
11func Init(svcName, version string, blockProfileRate int) {
12 if os.Getenv("GOOGLE_CLOUD_PROFILER_ENABLED") != "" {
13 err := profiler.Start(profiler.Config{
14 Service: svcName,
15 ServiceVersion: version,
16 MutexProfiling: true,
17 AllocForceGC: true,
18 })
19 if err != nil {
20 log.Printf("could not initialize profiler: %s", err.Error())
21 }
22 }
23}