Skip to content

Commit

Permalink
add metric for latest stored round
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott authored and hsanjuan committed Oct 5, 2020
1 parent c23577f commit 71c4729
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions chain/beacon/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (d *discrepancyStore) Put(b *chain.Beacon) error {
expected := chain.TimeOfRound(d.group.Period, d.group.GenesisTime, b.Round) * 1e9
discrepancy := float64(actual-expected) / float64(time.Millisecond)
metrics.BeaconDiscrepancyLatency.Set(float64(actual-expected) / float64(time.Millisecond))
metrics.LastBeaconRound.Set(float64(b.GetRound()))
d.l.Info("NEW_BEACON_STORED", b.String(), "time_discrepancy_ms", discrepancy)
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ var (
Name: "beacon_discrepancy_latency",
Help: "Discrepancy between beacon creation time and calculated round time",
})
// LastBeaconRound is the most recent round (as also seen at /health) stored.
LastBeaconRound = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "last_beacon_round",
Help: "Last locally stored beacon",
})

// HTTPCallCounter (HTTP) how many http requests
HTTPCallCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
Expand Down Expand Up @@ -159,6 +164,7 @@ func bindMetrics() error {
GroupDialFailures,
GroupConnections,
BeaconDiscrepancyLatency,
LastBeaconRound,
}
for _, c := range group {
if err := GroupMetrics.Register(c); err != nil {
Expand Down

0 comments on commit 71c4729

Please sign in to comment.