From ffd55e651272ec9fa25c90914e039c239b0923ec Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 14 Oct 2024 13:42:12 +0200 Subject: [PATCH] Enable pprof to investigate CPU usage in production --- go.mod | 1 + go.sum | 2 ++ internal/cmd/serve.go | 2 ++ 3 files changed, 5 insertions(+) diff --git a/go.mod b/go.mod index 6e303ea..c8aa358 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ go 1.23.0 require ( github.com/etherlabsio/healthcheck/v2 v2.0.0 github.com/getsentry/sentry-go v0.29.0 + github.com/gin-contrib/pprof v1.5.0 github.com/gin-gonic/gin v1.10.0 github.com/go-sql-driver/mysql v1.8.1 github.com/spf13/viper v1.19.0 diff --git a/go.sum b/go.sum index 8e7b858..47a3ae5 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,8 @@ github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s= github.com/getsentry/sentry-go v0.29.0 h1:YtWluuCFg9OfcqnaujpY918N/AhCCwarIDWOYSBAjCA= github.com/getsentry/sentry-go v0.29.0/go.mod h1:jhPesDAL0Q0W2+2YEuVOvdWmVtdsr1+jtBrlDEVWwLY= +github.com/gin-contrib/pprof v1.5.0 h1:E/Oy7g+kNw94KfdCy3bZxQFtyDnAX2V7axRS7sNYVrU= +github.com/gin-contrib/pprof v1.5.0/go.mod h1:GqFL6LerKoCQ/RSWnkYczkTJ+tOAUVN/8sbnEtaqOKs= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= diff --git a/internal/cmd/serve.go b/internal/cmd/serve.go index 9ebbbde..5a065c9 100644 --- a/internal/cmd/serve.go +++ b/internal/cmd/serve.go @@ -11,6 +11,7 @@ import ( "github.com/etherlabsio/healthcheck/v2" "github.com/getsentry/sentry-go" sentrygin "github.com/getsentry/sentry-go/gin" + "github.com/gin-contrib/pprof" "github.com/gin-gonic/gin" "go.uber.org/multierr" @@ -53,6 +54,7 @@ func Serve() error { } r := gin.Default() + pprof.Register(r) r.Use(sentrygin.New(sentrygin.Options{Repanic: true})) r.Use(sentryLogging.ErrorMiddleware()) r.Use(http.ErrorMiddleware())