Skip to content

Commit

Permalink
(BIDS-1335) add optional pprof endpoint to FDU for profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbitfly committed Jan 9, 2023
1 parent 945be21 commit dd4b9ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmd/frontend-data-updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (

_ "github.com/jackc/pgx/v4/stdlib"
"github.com/sirupsen/logrus"

"net/http"
_ "net/http/pprof"
)

func main() {
Expand All @@ -26,14 +29,13 @@ func main() {
utils.Config = cfg
logrus.WithField("config", *configPath).WithField("version", version.Version).WithField("chainName", utils.Config.Chain.Config.ConfigName).Printf("starting")

// ctx, done := context.WithTimeout(context.Background(), time.Second*30)
// defer done()
// db.MustInitBigtableAdmin(ctx, cfg.Bigtable.Project, cfg.Bigtable.Instance)

// err = db.BigAdminClient.SetupBigtableCache()
// if err != nil {
// logrus.Fatalf("error setting up bigtable cache err: %v", err)
// }
// enable pprof endpoint if requested
if utils.Config.Pprof.Enabled {
go func() {
logrus.Infof("starting pprof http server on port %s", utils.Config.Pprof.Port)
logrus.Info(http.ListenAndServe(fmt.Sprintf("localhost:%s", utils.Config.Pprof.Port), nil))
}()
}

_, err = db.InitBigtable(cfg.Bigtable.Project, cfg.Bigtable.Instance, fmt.Sprintf("%d", utils.Config.Chain.Config.DepositChainID))
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ type Config struct {
MevBoostRelayExporter struct {
Enabled bool `yaml:"enabled" envconfig:"MEVBOOSTRELAY_EXPORTER_ENABLED"`
} `yaml:"mevBoostRelayExporter"`
Pprof struct {
Enabled bool `yaml:"enabled" envconfig:"PPROF_ENABLED"`
Port string `yaml:"port" envconfig:"PPROF_PORT"`
} `yaml:"pprof"`
}

type DatabaseConfig struct {
Expand Down

0 comments on commit dd4b9ab

Please sign in to comment.