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