1
0
Fork 0

Merge pull request #892 from rqlite/more-snapshot-metrics

More Snapshot metrics
master
Philip O'Toole 3 years ago committed by GitHub
commit cf3d27fd89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -71,6 +71,8 @@ const (
numRemovedBeforeJoins = "num_removed_before_joins" numRemovedBeforeJoins = "num_removed_before_joins"
snapshotCreateDuration = "snapshot_create_duration" snapshotCreateDuration = "snapshot_create_duration"
snapshotPersistDuration = "snapshot_persist_duration" snapshotPersistDuration = "snapshot_persist_duration"
snapshotDBSerializedSize = "snapshot_db_serialized_size"
snapshotDBOnDiskSize = "snapshot_db_ondisk_size"
) )
// BackupFormat represents the format of database backup. // BackupFormat represents the format of database backup.
@ -99,6 +101,8 @@ func init() {
stats.Add(numRemovedBeforeJoins, 0) stats.Add(numRemovedBeforeJoins, 0)
stats.Add(snapshotCreateDuration, 0) stats.Add(snapshotCreateDuration, 0)
stats.Add(snapshotPersistDuration, 0) stats.Add(snapshotPersistDuration, 0)
stats.Add(snapshotDBSerializedSize, 0)
stats.Add(snapshotDBOnDiskSize, 0)
} }
// ClusterState defines the possible Raft states the current node can be in // ClusterState defines the possible Raft states the current node can be in
@ -1044,6 +1048,7 @@ func (s *Store) Snapshot() (raft.FSMSnapshot, error) {
dur := time.Since(fsm.startT) dur := time.Since(fsm.startT)
stats.Add(numSnaphots, 1) stats.Add(numSnaphots, 1)
stats.Get(snapshotCreateDuration).(*expvar.Int).Set(dur.Milliseconds()) stats.Get(snapshotCreateDuration).(*expvar.Int).Set(dur.Milliseconds())
stats.Get(snapshotDBSerializedSize).(*expvar.Int).Set(int64(len(fsm.database)))
s.logger.Printf("node snapshot created in %s", dur) s.logger.Printf("node snapshot created in %s", dur)
return fsm, nil return fsm, nil
} }
@ -1213,6 +1218,7 @@ func (f *fsmSnapshot) Persist(sink raft.SnapshotSink) error {
if _, err := sink.Write(cdb); err != nil { if _, err := sink.Write(cdb); err != nil {
return err return err
} }
stats.Get(snapshotDBOnDiskSize).(*expvar.Int).Set(int64(len(cdb)))
} else { } else {
f.logger.Println("no database data available for snapshot") f.logger.Println("no database data available for snapshot")
err = writeUint64(b, uint64(0)) err = writeUint64(b, uint64(0))
@ -1222,6 +1228,7 @@ func (f *fsmSnapshot) Persist(sink raft.SnapshotSink) error {
if _, err := sink.Write(b.Bytes()); err != nil { if _, err := sink.Write(b.Bytes()); err != nil {
return err return err
} }
stats.Get(snapshotDBOnDiskSize).(*expvar.Int).Set(0)
} }
// Close the sink. // Close the sink.

Loading…
Cancel
Save