Skip to content

Commit

Permalink
Init prometheus registry in main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanc committed May 14, 2024
1 parent 2a3281f commit b2662ce
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions avssync/avssync.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func NewAvsSync(
quorums []byte, fetchQuorumsDynamically bool, retrySyncNTimes int,
readerTimeoutDuration time.Duration, writerTimeoutDuration time.Duration,
prometheusServerAddr string,
prometheusRegistry *prometheus.Registry,
) *AvsSync {
promReg := prometheus.NewRegistry()
metrics := NewMetrics(promReg)
metrics := NewMetrics(prometheusRegistry, prometheusServerAddr)

Check failure on line 50 in avssync/avssync.go

View workflow job for this annotation

GitHub Actions / Run Tests

too many arguments in call to NewMetrics

return &AvsSync{
AvsReader: avsReader,
Expand Down
2 changes: 2 additions & 0 deletions avssync/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func NewMetrics(reg *prometheus.Registry) *Metrics {
Name: "operators_updated",
Help: "The total number of operators updated (during the last quorum sync)",
}, []string{"quorum"}),

registry: reg,
}

return metrics
Expand Down
2 changes: 2 additions & 0 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/common"
gethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/prometheus/client_golang/prometheus"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
"go.uber.org/mock/gomock"
Expand Down Expand Up @@ -274,6 +275,7 @@ func NewAvsSyncComponents(t *testing.T, anvilHttpEndpoint string, contractAddres
time.Second,
time.Second,
"", // no metrics server (otherwise parallel tests all try to start server at same endpoint and error out)
prometheus.NewRegistry(),
)
return &AvsSyncComponents{
avsSync: avsSync,
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/Layr-Labs/eigensdk-go/signerv2"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/prometheus/client_golang/prometheus"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -208,6 +209,10 @@ func avsSyncMain(cliCtx *cli.Context) error {
sleepBeforeFirstSyncDuration = firstSyncTime.Sub(now)
}
logger.Infof("Sleeping for %v before first sync, so that it happens at %v", sleepBeforeFirstSyncDuration, time.Now().Add(sleepBeforeFirstSyncDuration))

// Create new prometheus registry
reg := prometheus.NewRegistry()

avsSync := avssync.NewAvsSync(
logger,
avsReader,
Expand All @@ -221,6 +226,7 @@ func avsSyncMain(cliCtx *cli.Context) error {
readerTimeout,
writerTimeout,
cliCtx.String(MetricsAddrFlag.Name),
reg,
)

avsSync.Start(context.Background())
Expand Down

0 comments on commit b2662ce

Please sign in to comment.