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:
@@ -37,11 +37,11 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
if err == filer_pb.ErrNotFound {
|
if err == filer_pb.ErrNotFound {
|
||||||
glog.V(1).Infof("Not found %s: %v", path, err)
|
glog.V(1).Infof("Not found %s: %v", path, err)
|
||||||
stats.FilerRequestCounter.WithLabelValues("read.notfound").Inc()
|
stats.FilerRequestCounter.WithLabelValues(stats.ErrorReadNotFound).Inc()
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
} else {
|
} else {
|
||||||
glog.Errorf("Internal %s: %v", path, err)
|
glog.Errorf("Internal %s: %v", path, err)
|
||||||
stats.FilerRequestCounter.WithLabelValues("read.internalerror").Inc()
|
stats.FilerRequestCounter.WithLabelValues(stats.ErrorReadInternal).Inc()
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -162,7 +162,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
if offset+size <= int64(len(entry.Content)) {
|
if offset+size <= int64(len(entry.Content)) {
|
||||||
_, err := writer.Write(entry.Content[offset : offset+size])
|
_, err := writer.Write(entry.Content[offset : offset+size])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.FilerRequestCounter.WithLabelValues("write.entry.failed").Inc()
|
stats.FilerRequestCounter.WithLabelValues(stats.ErrorWriteEntry).Inc()
|
||||||
glog.Errorf("failed to write entry content: %v", err)
|
glog.Errorf("failed to write entry content: %v", err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@@ -174,7 +174,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
Directory: dir,
|
Directory: dir,
|
||||||
Name: name,
|
Name: name,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
stats.FilerRequestCounter.WithLabelValues("read.cache.failed").Inc()
|
stats.FilerRequestCounter.WithLabelValues(stats.ErrorReadCache).Inc()
|
||||||
glog.Errorf("CacheRemoteObjectToLocalCluster %s: %v", entry.FullPath, err)
|
glog.Errorf("CacheRemoteObjectToLocalCluster %s: %v", entry.FullPath, err)
|
||||||
return fmt.Errorf("cache %s: %v", entry.FullPath, err)
|
return fmt.Errorf("cache %s: %v", entry.FullPath, err)
|
||||||
} else {
|
} else {
|
||||||
@@ -184,7 +184,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
err = filer.StreamContent(fs.filer.MasterClient, writer, chunks, offset, size)
|
err = filer.StreamContent(fs.filer.MasterClient, writer, chunks, offset, size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.FilerRequestCounter.WithLabelValues("read.stream.failed").Inc()
|
stats.FilerRequestCounter.WithLabelValues(stats.ErrorReadStream).Inc()
|
||||||
glog.Errorf("failed to stream content %s: %v", r.URL, err)
|
glog.Errorf("failed to stream content %s: %v", r.URL, err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|||||||
31
weed/stats/metrics_names.go
Normal file
31
weed/stats/metrics_names.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package stats
|
||||||
|
|
||||||
|
// This file contains metric names for all errors
|
||||||
|
// The naming convention is ErrorSomeThing = "error.some.thing"
|
||||||
|
const (
|
||||||
|
// volume server
|
||||||
|
ErrorSizeMismatchOffsetSize = "errorSizeMismatchOffsetSize"
|
||||||
|
ErrorSizeMismatch = "errorSizeMismatch"
|
||||||
|
ErrorCRC = "errorCRC"
|
||||||
|
ErrorIndexOutOfRange = "errorIndexOutOfRange"
|
||||||
|
|
||||||
|
// master topology
|
||||||
|
ErrorWriteToLocalDisk = "errorWriteToLocalDisk"
|
||||||
|
ErrorUnmarshalPairs = "errorUnmarshalPairs"
|
||||||
|
ErrorWriteToReplicas = "errorWriteToReplicas"
|
||||||
|
|
||||||
|
// master client
|
||||||
|
FailedToKeepConnected = "failedToKeepConnected"
|
||||||
|
FailedToSend = "failedToSend"
|
||||||
|
FailedToReceive = "failedToReceive"
|
||||||
|
RedirectedToleader = "redirectedToleader"
|
||||||
|
OnPeerUpdate = "onPeerUpdate"
|
||||||
|
Failed = "failed"
|
||||||
|
|
||||||
|
// filer handler
|
||||||
|
ErrorReadNotFound = "read.notfound"
|
||||||
|
ErrorReadInternal = "read.internalerror"
|
||||||
|
ErrorWriteEntry = "write.entry.failed"
|
||||||
|
ErrorReadCache = "read.cache.failed"
|
||||||
|
ErrorReadStream = "read.stream.failed"
|
||||||
|
)
|
||||||
@@ -218,11 +218,11 @@ func (n *Needle) ReadBytes(bytes []byte, offset int64, size Size, version Versio
|
|||||||
if n.Size != size {
|
if n.Size != size {
|
||||||
// cookie is not always passed in for this API. Use size to do preliminary checking.
|
// cookie is not always passed in for this API. Use size to do preliminary checking.
|
||||||
if OffsetSize == 4 && offset < int64(MaxPossibleVolumeSize) {
|
if OffsetSize == 4 && offset < int64(MaxPossibleVolumeSize) {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorSizeMismatchOffsetSize").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorSizeMismatchOffsetSize).Inc()
|
||||||
glog.Errorf("entry not found1: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size)
|
glog.Errorf("entry not found1: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size)
|
||||||
return ErrorSizeMismatch
|
return ErrorSizeMismatch
|
||||||
}
|
}
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorSizeMismatch").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorSizeMismatch).Inc()
|
||||||
return fmt.Errorf("entry not found: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size)
|
return fmt.Errorf("entry not found: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size)
|
||||||
}
|
}
|
||||||
switch version {
|
switch version {
|
||||||
@@ -238,7 +238,7 @@ func (n *Needle) ReadBytes(bytes []byte, offset int64, size Size, version Versio
|
|||||||
checksum := util.BytesToUint32(bytes[NeedleHeaderSize+size : NeedleHeaderSize+size+NeedleChecksumSize])
|
checksum := util.BytesToUint32(bytes[NeedleHeaderSize+size : NeedleHeaderSize+size+NeedleChecksumSize])
|
||||||
newChecksum := NewCRC(n.Data)
|
newChecksum := NewCRC(n.Data)
|
||||||
if checksum != newChecksum.Value() {
|
if checksum != newChecksum.Value() {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorCRC").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorCRC).Inc()
|
||||||
return errors.New("CRC error! Data On Disk Corrupted")
|
return errors.New("CRC error! Data On Disk Corrupted")
|
||||||
}
|
}
|
||||||
n.Checksum = newChecksum
|
n.Checksum = newChecksum
|
||||||
@@ -271,7 +271,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
|||||||
n.DataSize = util.BytesToUint32(bytes[index : index+4])
|
n.DataSize = util.BytesToUint32(bytes[index : index+4])
|
||||||
index = index + 4
|
index = index + 4
|
||||||
if int(n.DataSize)+index > lenBytes {
|
if int(n.DataSize)+index > lenBytes {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||||
return fmt.Errorf("index out of range %d", 1)
|
return fmt.Errorf("index out of range %d", 1)
|
||||||
}
|
}
|
||||||
n.Data = bytes[index : index+int(n.DataSize)]
|
n.Data = bytes[index : index+int(n.DataSize)]
|
||||||
@@ -283,7 +283,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
|||||||
n.NameSize = uint8(bytes[index])
|
n.NameSize = uint8(bytes[index])
|
||||||
index = index + 1
|
index = index + 1
|
||||||
if int(n.NameSize)+index > lenBytes {
|
if int(n.NameSize)+index > lenBytes {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||||
return fmt.Errorf("index out of range %d", 2)
|
return fmt.Errorf("index out of range %d", 2)
|
||||||
}
|
}
|
||||||
n.Name = bytes[index : index+int(n.NameSize)]
|
n.Name = bytes[index : index+int(n.NameSize)]
|
||||||
@@ -293,7 +293,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
|||||||
n.MimeSize = uint8(bytes[index])
|
n.MimeSize = uint8(bytes[index])
|
||||||
index = index + 1
|
index = index + 1
|
||||||
if int(n.MimeSize)+index > lenBytes {
|
if int(n.MimeSize)+index > lenBytes {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||||
return fmt.Errorf("index out of range %d", 3)
|
return fmt.Errorf("index out of range %d", 3)
|
||||||
}
|
}
|
||||||
n.Mime = bytes[index : index+int(n.MimeSize)]
|
n.Mime = bytes[index : index+int(n.MimeSize)]
|
||||||
@@ -301,7 +301,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
|||||||
}
|
}
|
||||||
if index < lenBytes && n.HasLastModifiedDate() {
|
if index < lenBytes && n.HasLastModifiedDate() {
|
||||||
if LastModifiedBytesLength+index > lenBytes {
|
if LastModifiedBytesLength+index > lenBytes {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||||
return fmt.Errorf("index out of range %d", 4)
|
return fmt.Errorf("index out of range %d", 4)
|
||||||
}
|
}
|
||||||
n.LastModified = util.BytesToUint64(bytes[index : index+LastModifiedBytesLength])
|
n.LastModified = util.BytesToUint64(bytes[index : index+LastModifiedBytesLength])
|
||||||
@@ -309,7 +309,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
|||||||
}
|
}
|
||||||
if index < lenBytes && n.HasTtl() {
|
if index < lenBytes && n.HasTtl() {
|
||||||
if TtlBytesLength+index > lenBytes {
|
if TtlBytesLength+index > lenBytes {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||||
return fmt.Errorf("index out of range %d", 5)
|
return fmt.Errorf("index out of range %d", 5)
|
||||||
}
|
}
|
||||||
n.Ttl = LoadTTLFromBytes(bytes[index : index+TtlBytesLength])
|
n.Ttl = LoadTTLFromBytes(bytes[index : index+TtlBytesLength])
|
||||||
@@ -317,13 +317,13 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
|||||||
}
|
}
|
||||||
if index < lenBytes && n.HasPairs() {
|
if index < lenBytes && n.HasPairs() {
|
||||||
if 2+index > lenBytes {
|
if 2+index > lenBytes {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||||
return fmt.Errorf("index out of range %d", 6)
|
return fmt.Errorf("index out of range %d", 6)
|
||||||
}
|
}
|
||||||
n.PairsSize = util.BytesToUint16(bytes[index : index+2])
|
n.PairsSize = util.BytesToUint16(bytes[index : index+2])
|
||||||
index += 2
|
index += 2
|
||||||
if int(n.PairsSize)+index > lenBytes {
|
if int(n.PairsSize)+index > lenBytes {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||||
return fmt.Errorf("index out of range %d", 7)
|
return fmt.Errorf("index out of range %d", 7)
|
||||||
}
|
}
|
||||||
end := index + int(n.PairsSize)
|
end := index + int(n.PairsSize)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt
|
|||||||
if s.GetVolume(volumeId) != nil {
|
if s.GetVolume(volumeId) != nil {
|
||||||
isUnchanged, err = s.WriteVolumeNeedle(volumeId, n, true, fsync)
|
isUnchanged, err = s.WriteVolumeNeedle(volumeId, n, true, fsync)
|
||||||
if err != nil {
|
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)
|
err = fmt.Errorf("failed to write to local disk: %v", err)
|
||||||
glog.V(0).Infoln(err)
|
glog.V(0).Infoln(err)
|
||||||
return
|
return
|
||||||
@@ -76,7 +76,7 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt
|
|||||||
tmpMap := make(map[string]string)
|
tmpMap := make(map[string]string)
|
||||||
err := json.Unmarshal(n.Pairs, &tmpMap)
|
err := json.Unmarshal(n.Pairs, &tmpMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("errorUnmarshalPairs").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorUnmarshalPairs).Inc()
|
||||||
glog.V(0).Infoln("Unmarshal pairs error:", err)
|
glog.V(0).Infoln("Unmarshal pairs error:", err)
|
||||||
}
|
}
|
||||||
for k, v := range tmpMap {
|
for k, v := range tmpMap {
|
||||||
@@ -98,7 +98,7 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt
|
|||||||
_, err := operation.UploadData(n.Data, uploadOption)
|
_, err := operation.UploadData(n.Data, uploadOption)
|
||||||
return err
|
return err
|
||||||
}); err != nil {
|
}); 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)
|
err = fmt.Errorf("failed to write to replicas for volume %d: %v", volumeId, err)
|
||||||
glog.V(0).Infoln(err)
|
glog.V(0).Infoln(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
stream, err := client.KeepConnected(ctx)
|
stream, err := client.KeepConnected(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(1).Infof("%s masterClient failed to keep connected to %s: %v", mc.clientType, master, err)
|
glog.V(1).Infof("%s masterClient failed to keep connected to %s: %v", mc.clientType, master, err)
|
||||||
stats.MasterClientConnectCounter.WithLabelValues("failedToKeepConnected").Inc()
|
stats.MasterClientConnectCounter.WithLabelValues(stats.FailedToKeepConnected).Inc()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
Version: util.Version(),
|
Version: util.Version(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
glog.V(0).Infof("%s masterClient failed to send to %s: %v", mc.clientType, master, err)
|
glog.V(0).Infof("%s masterClient failed to send to %s: %v", mc.clientType, master, err)
|
||||||
stats.MasterClientConnectCounter.WithLabelValues("failedToSend").Inc()
|
stats.MasterClientConnectCounter.WithLabelValues(stats.FailedToSend).Inc()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
resp, err := stream.Recv()
|
resp, err := stream.Recv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("%s masterClient failed to receive from %s: %v", mc.clientType, master, err)
|
glog.V(0).Infof("%s masterClient failed to receive from %s: %v", mc.clientType, master, err)
|
||||||
stats.MasterClientConnectCounter.WithLabelValues("failedToReceive").Inc()
|
stats.MasterClientConnectCounter.WithLabelValues(stats.FailedToReceive).Inc()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
if resp.VolumeLocation.Leader != "" {
|
if resp.VolumeLocation.Leader != "" {
|
||||||
glog.V(0).Infof("redirected to leader %v", resp.VolumeLocation.Leader)
|
glog.V(0).Infof("redirected to leader %v", resp.VolumeLocation.Leader)
|
||||||
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader)
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader)
|
||||||
stats.MasterClientConnectCounter.WithLabelValues("redirectedToleader").Inc()
|
stats.MasterClientConnectCounter.WithLabelValues(stats.RedirectedToleader).Inc()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
} else {
|
} else {
|
||||||
glog.V(0).Infof("- %s %s leader:%v\n", update.NodeType, update.Address, update.IsLeader)
|
glog.V(0).Infof("- %s %s leader:%v\n", update.NodeType, update.Address, update.IsLeader)
|
||||||
}
|
}
|
||||||
stats.MasterClientConnectCounter.WithLabelValues("onPeerUpdate").Inc()
|
stats.MasterClientConnectCounter.WithLabelValues(stats.OnPeerUpdate).Inc()
|
||||||
mc.OnPeerUpdate(update)
|
mc.OnPeerUpdate(update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
|
|
||||||
})
|
})
|
||||||
if gprcErr != nil {
|
if gprcErr != nil {
|
||||||
stats.MasterClientConnectCounter.WithLabelValues("failed").Inc()
|
stats.MasterClientConnectCounter.WithLabelValues(stats.Failed).Inc()
|
||||||
glog.V(1).Infof("%s masterClient failed to connect with master %v: %v", mc.clientType, master, gprcErr)
|
glog.V(1).Infof("%s masterClient failed to connect with master %v: %v", mc.clientType, master, gprcErr)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user