File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import (
3434 "github.com/sourcegraph/sourcegraph/internal/httpcli"
3535 "github.com/sourcegraph/sourcegraph/internal/httpserver"
3636 "github.com/sourcegraph/sourcegraph/internal/logging"
37+ "github.com/sourcegraph/sourcegraph/internal/profiler"
3738 "github.com/sourcegraph/sourcegraph/internal/ratelimit"
3839 "github.com/sourcegraph/sourcegraph/internal/repos"
3940 "github.com/sourcegraph/sourcegraph/internal/trace"
@@ -52,6 +53,11 @@ func Main(enterpriseInit EnterpriseInit) {
5253 ctx := context .Background ()
5354 env .Lock ()
5455 env .HandleHelpFlag ()
56+
57+ if err := profiler .Init (); err != nil {
58+ log .Fatalf ("failed to start profiler: %v" , err )
59+ }
60+
5561 logging .Init ()
5662 tracer .Init ()
5763 trace .Init (true )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module github.com/sourcegraph/sourcegraph
33go 1.14
44
55require (
6+ cloud.google.com/go v0.56.0
67 cloud.google.com/go/bigquery v1.6.0 // indirect
78 cloud.google.com/go/pubsub v1.3.1
89 cloud.google.com/go/storage v1.6.0
Original file line number Diff line number Diff line change @@ -531,6 +531,7 @@ github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
531531github.com/golang/mock v1.3.1 /go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y =
532532github.com/golang/mock v1.4.0 /go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw =
533533github.com/golang/mock v1.4.1 /go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw =
534+ github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw =
534535github.com/golang/mock v1.4.3 /go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw =
535536github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls =
536537github.com/golang/protobuf v1.3.5 /go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk =
Original file line number Diff line number Diff line change 1+ package profiler
2+
3+ import (
4+ "cloud.google.com/go/profiler"
5+
6+ "github.com/sourcegraph/sourcegraph/cmd/frontend/envvar"
7+ "github.com/sourcegraph/sourcegraph/internal/env"
8+ "github.com/sourcegraph/sourcegraph/internal/version"
9+ )
10+
11+ // Init starts the Google Cloud Profiler when in sourcegraph.com mode.
12+ // https://cloud.google.com/profiler/docs/profiling-go
13+ func Init () error {
14+ if ! envvar .SourcegraphDotComMode () {
15+ return nil
16+ }
17+
18+ return profiler .Start (profiler.Config {
19+ Service : env .MyName ,
20+ ServiceVersion : version .Version (),
21+ MutexProfiling : true ,
22+ AllocForceGC : true ,
23+ })
24+ }
You can’t perform that action at this time.
0 commit comments