From f3cec0c9fed730c1d852420bbf57a3852ff583ef Mon Sep 17 00:00:00 2001 From: pschork <354473+pschork@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:40:12 -0700 Subject: [PATCH] Add per quorum semever stake percentage metrics (#856) --- disperser/dataapi/metrics.go | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/disperser/dataapi/metrics.go b/disperser/dataapi/metrics.go index cea735c938..938b780c6d 100644 --- a/disperser/dataapi/metrics.go +++ b/disperser/dataapi/metrics.go @@ -26,9 +26,13 @@ type Metrics struct { NumRequests *prometheus.CounterVec Latency *prometheus.SummaryVec - Semvers *prometheus.GaugeVec OperatorsStake *prometheus.GaugeVec + Semvers *prometheus.GaugeVec + SemversStakePctQuorum0 *prometheus.GaugeVec + SemversStakePctQuorum1 *prometheus.GaugeVec + SemversStakePctQuorum2 *prometheus.GaugeVec + httpPort string logger logging.Logger } @@ -64,6 +68,27 @@ func NewMetrics(blobMetadataStore *blobstore.BlobMetadataStore, httpPort string, }, []string{"semver"}, ), + SemversStakePctQuorum0: promauto.With(reg).NewGaugeVec( + prometheus.GaugeOpts{ + Name: "node_semvers_stake_pct_quorum_0", + Help: "Node semver stake percentage in quorum 0", + }, + []string{"semver_stake_pct_quorum_0"}, + ), + SemversStakePctQuorum1: promauto.With(reg).NewGaugeVec( + prometheus.GaugeOpts{ + Name: "node_semvers_stake_pct_quorum_1", + Help: "Node semver stake percentage in quorum 1", + }, + []string{"semver_stake_pct_quorum_1"}, + ), + SemversStakePctQuorum2: promauto.With(reg).NewGaugeVec( + prometheus.GaugeOpts{ + Name: "node_semvers_stake_pct_quorum_2", + Help: "Node semver stake percentage in quorum 2", + }, + []string{"semver_stake_pct_quorum_2"}, + ), OperatorsStake: promauto.With(reg).NewGaugeVec( prometheus.GaugeOpts{ Namespace: namespace, @@ -114,6 +139,18 @@ func (g *Metrics) IncrementNotFoundRequestNum(method string) { func (g *Metrics) UpdateSemverCounts(semverData map[string]*semver.SemverMetrics) { for semver, metrics := range semverData { g.Semvers.WithLabelValues(semver).Set(float64(metrics.Operators)) + for quorum, stakePct := range metrics.QuorumStakePercentage { + switch quorum { + case 0: + g.SemversStakePctQuorum0.WithLabelValues(semver).Set(stakePct) + case 1: + g.SemversStakePctQuorum1.WithLabelValues(semver).Set(stakePct) + case 2: + g.SemversStakePctQuorum2.WithLabelValues(semver).Set(stakePct) + default: + g.logger.Error("Unable to log semver quorum stake percentage for quorum", "semver", semver, "quorum", quorum, "stake", stakePct) + } + } } }