From 57a55201574ed6ed17fe0d6b4f3f7621874dd85a Mon Sep 17 00:00:00 2001 From: Alex Robinson Date: Thu, 16 Jul 2015 09:52:10 -0700 Subject: [PATCH] snap: Record the snapshot save duration on success rather than only on error. It makes more sense to record the latency of successes (or all attempts) than of only a particular failure case. --- snap/snapshotter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapshotter.go b/snap/snapshotter.go index 764cc63ab..57d7d320c 100644 --- a/snap/snapshotter.go +++ b/snap/snapshotter.go @@ -75,7 +75,7 @@ func (s *Snapshotter) save(snapshot *raftpb.Snapshot) error { return err } err = ioutil.WriteFile(path.Join(s.dir, fname), d, 0666) - if err != nil { + if err == nil { saveDurations.Observe(float64(time.Since(start).Nanoseconds() / int64(time.Microsecond))) } return err