move error to a separate file

This file contains metric names for all errors
The naming convention is ErrorSomeThing = "error.some.thing"
This commit is contained in:
chrislu
2022-02-04 22:57:51 -08:00
parent a23fcb9a7c
commit 433fde4b18
5 changed files with 55 additions and 24 deletions

View File

@@ -45,7 +45,7 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt
if s.GetVolume(volumeId) != nil {
isUnchanged, err = s.WriteVolumeNeedle(volumeId, n, true, fsync)
if err != nil {
stats.VolumeServerRequestCounter.WithLabelValues("errorWriteToLocalDisk").Inc()
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorWriteToLocalDisk).Inc()
err = fmt.Errorf("failed to write to local disk: %v", err)
glog.V(0).Infoln(err)
return
@@ -76,7 +76,7 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt
tmpMap := make(map[string]string)
err := json.Unmarshal(n.Pairs, &tmpMap)
if err != nil {
stats.VolumeServerRequestCounter.WithLabelValues("errorUnmarshalPairs").Inc()
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorUnmarshalPairs).Inc()
glog.V(0).Infoln("Unmarshal pairs error:", err)
}
for k, v := range tmpMap {
@@ -98,7 +98,7 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt
_, err := operation.UploadData(n.Data, uploadOption)
return err
}); err != nil {
stats.VolumeServerRequestCounter.WithLabelValues("errorWriteToReplicas").Inc()
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorWriteToReplicas).Inc()
err = fmt.Errorf("failed to write to replicas for volume %d: %v", volumeId, err)
glog.V(0).Infoln(err)
}