瀏覽代碼

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.
Alex Robinson 10 年之前
父節點
當前提交
57a5520157
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      snap/snapshotter.go

+ 1 - 1
snap/snapshotter.go

@@ -75,7 +75,7 @@ func (s *Snapshotter) save(snapshot *raftpb.Snapshot) error {
 		return err
 		return err
 	}
 	}
 	err = ioutil.WriteFile(path.Join(s.dir, fname), d, 0666)
 	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)))
 		saveDurations.Observe(float64(time.Since(start).Nanoseconds() / int64(time.Microsecond)))
 	}
 	}
 	return err
 	return err