Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add pprof http endpoints (#1401)
Yilong Li657343a70287
diff --git a/server/pprof.go b/server/pprof.gonew file mode 100644index 0000000000..f7ac331b8b--- /dev/null+++ b/server/pprof.go@@ -0,0 +1,22 @@+package server++import (+ "net/http"+ "net/http/pprof"++ "github.com/labstack/echo/v4"+)++// registerPProfEndpoints adds several routes from package `net/http/pprof` to *echo.Echo object.+func registerPProfEndpoints(e *echo.Echo) {+ e.GET("/debug/pprof/", echo.WrapHandler(http.HandlerFunc(pprof.Index)))+ e.GET("/debug/pprof/allocs", echo.WrapHandler(http.HandlerFunc(pprof.Index)))+ e.GET("/debug/pprof/block", echo.WrapHandler(http.HandlerFunc(pprof.Index)))+ e.GET("/debug/pprof/goroutine", echo.WrapHandler(http.HandlerFunc(pprof.Index)))+ e.GET("/debug/pprof/heap", echo.WrapHandler(http.HandlerFunc(pprof.Index)))+ e.GET("/debug/pprof/mutex", echo.WrapHandler(http.HandlerFunc(pprof.Index)))+ e.GET("/debug/pprof/cmdline", echo.WrapHandler(http.HandlerFunc(pprof.Cmdline)))+ e.GET("/debug/pprof/profile", echo.WrapHandler(http.HandlerFunc(pprof.Profile)))+ e.GET("/debug/pprof/symbol", echo.WrapHandler(http.HandlerFunc(pprof.Symbol)))+ e.GET("/debug/pprof/trace", echo.WrapHandler(http.HandlerFunc(pprof.Trace)))+}diff --git a/server/server.go b/server/server.goindex ed62b0a867..d8a6f34814 100644--- a/server/server.go+++ b/server/server.go@@ -9,25 +9,25 @@ import ("sync""time"- "github.com/bytebase/bytebase/common"- "github.com/bytebase/bytebase/metric"- metricCollector "github.com/bytebase/bytebase/metric/collector"- "github.com/bytebase/bytebase/resources/mysqlbinlog"- "github.com/bytebase/bytebase/store"- "github.com/google/uuid"-// embed will embeds the acl policy._ "embed"- "github.com/bytebase/bytebase/api"- enterpriseAPI "github.com/bytebase/bytebase/enterprise/api"- enterpriseService "github.com/bytebase/bytebase/enterprise/service""github.com/casbin/casbin/v2""github.com/casbin/casbin/v2/model"+ "github.com/google/uuid""github.com/labstack/echo/v4""github.com/labstack/echo/v4/middleware"scas "github.com/qiangmzsx/string-adapter/v2""go.uber.org/zap"++ "github.com/bytebase/bytebase/api"+ "github.com/bytebase/bytebase/common"+ enterpriseAPI "github.com/bytebase/bytebase/enterprise/api"+ enterpriseService "github.com/bytebase/bytebase/enterprise/service"+ "github.com/bytebase/bytebase/metric"+ metricCollector "github.com/bytebase/bytebase/metric/collector"+ "github.com/bytebase/bytebase/resources/mysqlbinlog"+ "github.com/bytebase/bytebase/store")// Server is the Bytebase server.@@ -297,6 +297,8 @@ func NewServer(ctx context.Context, prof Profile, logger *zap.Logger, loggerLevee.GET("/healthz", func(c echo.Context) error {return c.String(http.StatusOK, "OK!\n")})+ // Register pprof endpoints.+ registerPProfEndpoints(e)allRoutes, err := json.MarshalIndent(e.Routes(), "", " ")if err != nil {