Skip to content

Commit

Permalink
fix: only report lag when both heights are known
Browse files Browse the repository at this point in the history
  • Loading branch information
0x416e746f6e committed Mar 17, 2024
1 parent 444191b commit 8b36dc2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ func (s *Server) handleEventPrometheusObserve(_ context.Context, o metric.Observ
o.ObserveInt64(s.metrics.highestBlock, blockEndpoint, metric.WithAttributes(attrs...))

// endpoint's highest block lag
o.ObserveInt64(s.metrics.highestBlockLag, blockGroup-blockEndpoint, metric.WithAttributes(attrs...))
var lag int64
if blockGroup != 0 && blockEndpoint != 0 {
lag = blockGroup - blockEndpoint
}
o.ObserveInt64(s.metrics.highestBlockLag, lag, metric.WithAttributes(attrs...))

// endpoint's time since last block
o.ObserveFloat64(s.metrics.timeSinceLastBlock, tsBlockEndpoint.Seconds(), metric.WithAttributes(attrs...))
Expand Down

0 comments on commit 8b36dc2

Please sign in to comment.