Enable pprof to investigate CPU usage in production

This commit is contained in:
ErickSkrauch 2024-10-14 13:42:12 +02:00
parent ca840c1cc5
commit ffd55e6512
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
3 changed files with 5 additions and 0 deletions

1
go.mod
View File

@ -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

2
go.sum
View File

@ -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=

View File

@ -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())