Skip to content

Commit

Permalink
beacon: add public metrics for current and next epoch (#4813)
Browse files Browse the repository at this point in the history
  • Loading branch information
countvonzero committed Aug 10, 2023
1 parent 2bb72a4 commit f341b86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spacemeshos/go-spacemesh/common/types/result"
"github.com/spacemeshos/go-spacemesh/datastore"
"github.com/spacemeshos/go-spacemesh/log"
"github.com/spacemeshos/go-spacemesh/metrics/public"
"github.com/spacemeshos/go-spacemesh/p2p/pubsub"
"github.com/spacemeshos/go-spacemesh/signing"
"github.com/spacemeshos/go-spacemesh/sql"
Expand Down Expand Up @@ -506,6 +507,13 @@ func (pd *ProtocolDriver) setBeacon(targetEpoch types.EpochID, beacon types.Beac
}
pd.beacons[targetEpoch] = beacon
pd.onResult(targetEpoch, beacon)
curr := pd.clock.CurrentLayer().GetEpoch()
switch targetEpoch {
case curr:
public.CurrentBeacon.WithLabelValues(beacon.String())
case curr + 1:
public.NextBeacon.WithLabelValues(beacon.String())
}
return nil
}

Expand Down
10 changes: 10 additions & 0 deletions metrics/public/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ var (
Namespace: "smh",
Name: "version",
}, []string{"version"})
CurrentBeacon = promauto.With(Registry).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "smh",
Subsystem: "beacon",
Name: "current",
}, []string{"beacon"})
NextBeacon = promauto.With(Registry).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "smh",
Subsystem: "beacon",
Name: "next",
}, []string{"beacon"})

SmeshingOptsProvingNonces = promauto.With(Registry).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "smh",
Expand Down

0 comments on commit f341b86

Please sign in to comment.