Skip to content

Commit 1e567e9

Browse files
committed
feat: report replication lag for primary as well
1 parent d0ffe2c commit 1e567e9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

monitoring/replication.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ func getReplicationLag(ctx context.Context, cl *mongo.Client) ([]*replicationLag
4444
return nil, errors.New("no primary detected")
4545
}
4646

47-
var lag []*replicationLag
47+
lag := make([]*replicationLag, 0, len(status.Members))
4848
for _, m := range status.Members {
49-
if m.StateStr != "PRIMARY" {
50-
lag = append(lag, &replicationLag{
51-
host: m.Name,
52-
lag: optimePrimary.Sub(m.OptimeDate),
53-
})
54-
}
49+
lag = append(lag, &replicationLag{
50+
host: m.Name,
51+
lag: optimePrimary.Sub(m.OptimeDate),
52+
})
5553
}
5654

5755
return lag, nil

0 commit comments

Comments
 (0)