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