From 6e89e8d4f7233e66998b9235bb197114a2366163 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sun, 6 May 2018 10:43:45 +0200 Subject: [PATCH] Add profiling support for cloud.google.com - Adds dependency on env var GOOGLE_APPLICATION_CREDENTIALS, which should contain a json file with a service key --- cmd/server/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/server/main.go b/cmd/server/main.go index caa18fa..2fdbabb 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -31,6 +31,7 @@ import ( "linkheader" + "cloud.google.com/go/profiler" "github.com/garyburd/redigo/redis" "github.com/pstuifzand/microsub-server/microsub" "github.com/pstuifzand/microsub-server/pkg/util" @@ -299,6 +300,14 @@ func newPool(addr string) *redis.Pool { } func main() { + if err := profiler.Start(profiler.Config{ + Service: "microsub-server", + ServiceVersion: "1.0", + ProjectID: "microsub-server", // optional on GCP + }); err != nil { + log.Fatalf("Cannot start the profiler: %v", err) + } + flag.Parse() createBackend := false