Skip to content

Commit

Permalink
skip metrics collection when oeprator has not registered yet (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf authored Nov 2, 2023
1 parent 21505ce commit 17af156
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion metrics/collectors/economic/economic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package economic

import (
"context"
"errors"
"strconv"

"github.com/Layr-Labs/eigensdk-go/chainio/avsregistry"
Expand Down Expand Up @@ -113,8 +114,12 @@ func (ec *Collector) initOperatorId() error {
if ec.operatorId == [32]byte{} {
operatorId, err := ec.avsRegistryReader.GetOperatorId(context.Background(), ec.operatorAddr)
if err != nil {
ec.logger.Error("Failed to get operator id", "err", err)
return err
}
if operatorId == [32]byte{} {
return errors.New("operator not registered")
}
ec.operatorId = operatorId
}
return nil
Expand Down Expand Up @@ -144,7 +149,7 @@ func (ec *Collector) Collect(ch chan<- prometheus.Metric) {
// collect registeredStake metric
err = ec.initOperatorId()
if err != nil {
ec.logger.Error("Failed to fetch and catch operator id. Skipping collection of registeredStake metric.", "err", err)
ec.logger.Warn("Failed to fetch and cache operator id. Skipping collection of registeredStake metric.", "err", err)
} else {
// probably should start using the avsregistry service instead of avsRegistryReader so that we can
// swap out backend for a subgraph eventually
Expand Down

0 comments on commit 17af156

Please sign in to comment.