Skip to content

Commit

Permalink
Observability - implement validator count gauge, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-ssvlabs committed Dec 5, 2024
1 parent c02251d commit bc73a8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions operator/validator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"math"
"sync"
"time"

Expand Down Expand Up @@ -310,6 +311,9 @@ func (c *controller) GetValidatorStats() (uint64, uint64, uint64, error) {
active++
}
}
if operatorShares <= math.MaxInt64 {
validatorsCountGauge.Record(c.ctx, int64(operatorShares))
}
return uint64(len(allShares)), active, operatorShares, nil
}

Expand Down
7 changes: 6 additions & 1 deletion operator/validator/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ var (

validatorStatusCounter = observability.NewMetric(
meter.Int64Counter(
metricName("validators"),
metricName("validators.per_status"),
metric.WithDescription("total number of validators by status")))

validatorsCountGauge = observability.NewMetric(
meter.Int64Gauge(
metricName("validators.active"),
metric.WithDescription("number of active validators")))
)

func metricName(name string) string {
Expand Down

0 comments on commit bc73a8e

Please sign in to comment.