Skip to content

Commit

Permalink
fix(metrics): reset labeled gauge vec
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo committed Feb 4, 2023
1 parent c9928e7 commit 407ef3d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/app/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ func (e *Exporter) collectStatus(ctx context.Context) error {
isSyncing = 1
}

e.metrics.ChainID.WithLabelValues(status.ChainID).Set(float64(HashString(status.ChainID)))
e.metrics.VersionBuild.WithLabelValues(status.Version.Version, status.Version.Build).Set(float64(HashString(status.Version.Build)))
e.metrics.BlockNumber.Set(float64(status.SyncInfo.LatestBlockHeight))
e.metrics.ChainID.WithLabelValues(status.ChainID).Set(float64(HashString(status.ChainID)))
e.metrics.SyncingDesc.Set(float64(isSyncing))
e.metrics.VersionBuild.WithLabelValues(status.Version.Version, status.Version.Build).Set(float64(HashString(status.Version.Build)))

return nil
}
Expand All @@ -139,11 +139,23 @@ func (e *Exporter) collectValidators(ctx context.Context) error {
return err
}

// Reset labeled gauge vec
e.metrics.ValidatorExpectedBlocks.Reset()
e.metrics.ValidatorExpectedChunks.Reset()
e.metrics.ValidatorProducedBlocks.Reset()
e.metrics.ValidatorProducedChunks.Reset()
e.metrics.ValidatorSlashed.Reset()
e.metrics.ValidatorStake.Reset()
e.metrics.NextValidatorStake.Reset()
e.metrics.CurrentProposals.Reset()
e.metrics.PrevEpochKickout.Reset()

labelEpochStartHeight := strconv.FormatInt(validators.EpochStartHeight, 10)

e.metrics.EpochStartHeight.Set(float64(validators.EpochStartHeight))

var seatPrice float64

for _, v := range validators.CurrentValidators {
isSlashed := 0
if v.IsSlashed {
Expand Down

0 comments on commit 407ef3d

Please sign in to comment.