Stop passing error details to prometheus metrics

pull/197/head
Martin Boehm 2019-06-04 13:09:15 +02:00
parent c409a350c9
commit d7d596bf4b
4 changed files with 8 additions and 8 deletions

View File

@ -152,7 +152,7 @@ type blockChainWithMetrics struct {
func (c *blockChainWithMetrics) observeRPCLatency(method string, start time.Time, err error) {
var e string
if err != nil {
e = err.Error()
e = "failure"
}
c.m.RPCLatency.With(common.Labels{"method": method, "error": e}).Observe(float64(time.Since(start)) / 1e6) // in milliseconds
}
@ -301,7 +301,7 @@ type mempoolWithMetrics struct {
func (c *mempoolWithMetrics) observeRPCLatency(method string, start time.Time, err error) {
var e string
if err != nil {
e = err.Error()
e = "failure"
}
c.m.RPCLatency.With(common.Labels{"method": method, "error": e}).Observe(float64(time.Since(start)) / 1e6) // in milliseconds
}

View File

@ -78,7 +78,7 @@ func (w *SyncWorker) ResyncIndex(onNewBlock bchain.OnNewBlockFunc, initialSync b
return nil
}
w.metrics.IndexResyncErrors.With(common.Labels{"error": err.Error()}).Inc()
w.metrics.IndexResyncErrors.With(common.Labels{"error": "failure"}).Inc()
return err
}
@ -300,7 +300,7 @@ func (w *SyncWorker) ConnectBlocksParallel(lower, higher uint32) error {
return
}
glog.Error("getBlockWorker ", i, " connect block error ", err, ". Retrying...")
w.metrics.IndexResyncErrors.With(common.Labels{"error": err.Error()}).Inc()
w.metrics.IndexResyncErrors.With(common.Labels{"error": "failure"}).Inc()
time.Sleep(time.Millisecond * 500)
} else {
break
@ -338,7 +338,7 @@ ConnectLoop:
hash, err = w.chain.GetBlockHash(h)
if err != nil {
glog.Error("GetBlockHash error ", err)
w.metrics.IndexResyncErrors.With(common.Labels{"error": err.Error()}).Inc()
w.metrics.IndexResyncErrors.With(common.Labels{"error": "failure"}).Inc()
time.Sleep(time.Millisecond * 500)
continue
}

View File

@ -185,7 +185,7 @@ func (s *SocketIoServer) onMessage(c *gosocketio.Channel, req map[string]json.Ra
return rv
}
glog.Error(c.Id(), " onMessage ", method, ": ", errors.ErrorStack(err))
s.metrics.SocketIORequests.With(common.Labels{"method": method, "status": err.Error()}).Inc()
s.metrics.SocketIORequests.With(common.Labels{"method": method, "status": "failure"}).Inc()
e := resultError{}
e.Error.Message = err.Error()
return e
@ -670,7 +670,7 @@ func (s *SocketIoServer) onSubscribe(c *gosocketio.Channel, req []byte) interfac
onError := func(id, sc, err, detail string) {
glog.Error(id, " onSubscribe ", err, ": ", detail)
s.metrics.SocketIOSubscribes.With(common.Labels{"channel": sc, "status": err}).Inc()
s.metrics.SocketIOSubscribes.With(common.Labels{"channel": sc, "status": "failure"}).Inc()
}
r := string(req)

View File

@ -341,7 +341,7 @@ func (s *WebsocketServer) onRequest(c *websocketChannel, req *websocketReq) {
s.metrics.WebsocketRequests.With(common.Labels{"method": req.Method, "status": "success"}).Inc()
} else {
glog.Error("Client ", c.id, " onMessage ", req.Method, ": ", errors.ErrorStack(err))
s.metrics.WebsocketRequests.With(common.Labels{"method": req.Method, "status": err.Error()}).Inc()
s.metrics.WebsocketRequests.With(common.Labels{"method": req.Method, "status": "failure"}).Inc()
e := resultError{}
e.Error.Message = err.Error()
data = e