Skip to content

Commit

Permalink
(NOBIDS) consolidate exposing metrics on all processes (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush authored Jul 31, 2024
1 parent 25580d8 commit 1bb0d64
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backend/cmd/blobindexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"

"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/metrics"
"github.com/gobitfly/beaconchain/pkg/commons/types"
"github.com/gobitfly/beaconchain/pkg/commons/utils"
"github.com/gobitfly/beaconchain/pkg/commons/version"
Expand All @@ -24,6 +25,14 @@ func main() {
if err != nil {
log.Fatal(err, "error reading config file", 0)
}
if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}
blobIndexer, err := blobindexer.NewBlobIndexer()
if err != nil {
log.Fatal(err, "error initializing blob indexer", 0)
Expand Down
11 changes: 11 additions & 0 deletions backend/cmd/eth1indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/gobitfly/beaconchain/pkg/commons/db"
"github.com/gobitfly/beaconchain/pkg/commons/erc20"
"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/metrics"
"github.com/gobitfly/beaconchain/pkg/commons/rpc"
"github.com/gobitfly/beaconchain/pkg/commons/services"
"github.com/gobitfly/beaconchain/pkg/commons/types"
Expand Down Expand Up @@ -89,6 +90,16 @@ func main() {
utils.Config = cfg

log.InfoWithFields(log.Fields{"config": *configPath, "version": version.Version, "chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

// enable pprof endpoint if requested
if utils.Config.Pprof.Enabled {
go func() {
Expand Down
10 changes: 10 additions & 0 deletions backend/cmd/ethstore_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/gobitfly/beaconchain/pkg/commons/db"
"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/metrics"
"github.com/gobitfly/beaconchain/pkg/commons/types"
"github.com/gobitfly/beaconchain/pkg/commons/utils"
"github.com/gobitfly/beaconchain/pkg/commons/version"
Expand Down Expand Up @@ -47,6 +48,15 @@ func main() {

log.InfoWithFields(log.Fields{"config": *configPath, "version": version.Version, "chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Expand Down
9 changes: 9 additions & 0 deletions backend/cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ func main() {

log.InfoWithFields(log.Fields{"config": *configPath, "version": version.Version, "commit": version.GitCommit, "chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

wg := &sync.WaitGroup{}
if !cfg.JustV2 {
wg.Add(1)
Expand Down
9 changes: 9 additions & 0 deletions backend/cmd/node_jobs_processor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ func main() {
"version": version.Version,
"chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Expand Down
9 changes: 9 additions & 0 deletions backend/cmd/notification_collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ func main() {
log.Fatal(err, "invalid chain configuration specified, you must specify the slots per epoch, seconds per slot and genesis timestamp in the config file", 0)
}

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

if utils.Config.Pprof.Enabled {
go func() {
log.Infof("starting pprof http server on port %s", utils.Config.Pprof.Port)
Expand Down
9 changes: 9 additions & 0 deletions backend/cmd/notification_sender/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ func main() {
log.Fatal(err, "invalid chain configuration specified, you must specify the slots per epoch, seconds per slot and genesis timestamp in the config file", 0)
}

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

if utils.Config.Pprof.Enabled {
go func() {
log.Infof("starting pprof http server on port %s", utils.Config.Pprof.Port)
Expand Down
10 changes: 10 additions & 0 deletions backend/cmd/rewards_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/gobitfly/beaconchain/pkg/commons/cache"
"github.com/gobitfly/beaconchain/pkg/commons/db"
"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/metrics"
"github.com/gobitfly/beaconchain/pkg/commons/services"
"github.com/gobitfly/beaconchain/pkg/commons/types"
"github.com/gobitfly/beaconchain/pkg/commons/utils"
Expand Down Expand Up @@ -52,6 +53,15 @@ func main() {

log.InfoWithFields(log.Fields{"config": *configPath, "version": version.Version, "chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Expand Down
9 changes: 9 additions & 0 deletions backend/cmd/signatures/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ func main() {
utils.Config = cfg
log.InfoWithFields(log.Fields{"config": *configPath, "chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Expand Down
10 changes: 10 additions & 0 deletions backend/cmd/statistics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gobitfly/beaconchain/pkg/commons/cache"
"github.com/gobitfly/beaconchain/pkg/commons/db"
"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/metrics"
"github.com/gobitfly/beaconchain/pkg/commons/price"
"github.com/gobitfly/beaconchain/pkg/commons/rpc"
"github.com/gobitfly/beaconchain/pkg/commons/services"
Expand Down Expand Up @@ -70,6 +71,15 @@ func main() {
log.Infof("Writing statistic with: SlotsPerEpoch [%v] or SecondsPerSlot [%v]", utils.Config.Chain.ClConfig.SlotsPerEpoch, utils.Config.Chain.ClConfig.SecondsPerSlot)
}

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

db.WriterDb, db.ReaderDb = db.MustInitDB(&types.DatabaseConfig{
Username: cfg.WriterDatabase.Username,
Password: cfg.WriterDatabase.Password,
Expand Down
9 changes: 9 additions & 0 deletions backend/cmd/user_service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ func main() {
log.Fatal(err, "invalid chain configuration specified, you must specify the slots per epoch, seconds per slot and genesis timestamp in the config file", 0)
}

if utils.Config.Metrics.Enabled {
go func(addr string) {
log.Infof("serving metrics on %v", addr)
if err := metrics.Serve(addr); err != nil {
log.Fatal(err, "error serving metrics", 0)
}
}(utils.Config.Metrics.Address)
}

if utils.Config.Pprof.Enabled {
go func() {
log.Infof("starting pprof http server on port %s", utils.Config.Pprof.Port)
Expand Down

0 comments on commit 1bb0d64

Please sign in to comment.