Skip to content

Commit

Permalink
Observe resumed heartbeat after failures (hashicorp#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrime authored Jun 22, 2021
1 parent f7242e7 commit 7bba491
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ type FailedHeartbeatObservation struct {
LastContact time.Time
}

// ResumedHeartbeatObservation is sent when a node resumes to heartbeat with the leader following failures
type ResumedHeartbeatObservation struct {
PeerID ServerID
}

// nextObserverId is used to provide a unique ID for each observer to aid in
// deregistration.
var nextObserverID uint64
Expand Down
3 changes: 3 additions & 0 deletions replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ func (r *Raft) heartbeat(s *followerReplication, stopCh chan struct{}) {
case <-stopCh:
}
} else {
if failures > 0 {
r.observe(ResumedHeartbeatObservation{PeerID: s.peer.ID})
}
s.setLastContact()
failures = 0
labels := []metrics.Label{{Name: "peer_id", Value: string(s.peer.ID)}}
Expand Down

0 comments on commit 7bba491

Please sign in to comment.