From d7d596bf4bddecdaaca03c95d4e38c89da205b41 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Tue, 4 Jun 2019 13:09:15 +0200 Subject: [PATCH] Stop passing error details to prometheus metrics --- bchain/coins/blockchain.go | 4 ++-- db/sync.go | 6 +++--- server/socketio.go | 4 ++-- server/websocket.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bchain/coins/blockchain.go b/bchain/coins/blockchain.go index 06022cf7..9256f048 100644 --- a/bchain/coins/blockchain.go +++ b/bchain/coins/blockchain.go @@ -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 } diff --git a/db/sync.go b/db/sync.go index c5415c72..1f2ef232 100644 --- a/db/sync.go +++ b/db/sync.go @@ -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 } diff --git a/server/socketio.go b/server/socketio.go index 4b350f27..1238edbf 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -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) diff --git a/server/websocket.go b/server/websocket.go index e9018dca..48111e1f 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -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