Skip to content

Commit

Permalink
Add metrics profiling within appendEntries RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Apr 8, 2015
1 parent a88bfa8 commit 8344801
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ func (r *Raft) appendEntries(rpc RPC, a *AppendEntriesRequest) {

// Process any new entries
if n := len(a.Entries); n > 0 {
start := time.Now()
first := a.Entries[0]
last := a.Entries[n-1]

Expand All @@ -1282,13 +1283,16 @@ func (r *Raft) appendEntries(rpc RPC, a *AppendEntriesRequest) {
// Update the lastLog
r.setLastLogIndex(last.Index)
r.setLastLogTerm(last.Term)
metrics.MeasureSince([]string{"raft", "rpc", "appendEntries", "storeLogs"}, start)
}

// Update the commit index
if a.LeaderCommitIndex > 0 && a.LeaderCommitIndex > r.getCommitIndex() {
start := time.Now()
idx := min(a.LeaderCommitIndex, r.getLastIndex())
r.setCommitIndex(idx)
r.processLogs(idx, nil)
metrics.MeasureSince([]string{"raft", "rpc", "appendEntries", "processLogs"}, start)
}

// Everything went well, set success
Expand Down

0 comments on commit 8344801

Please sign in to comment.