Skip to content
Permalink
Browse files

Stop passing error details to prometheus metrics

  • Loading branch information...
martinboehm committed Jun 4, 2019
1 parent c409a35 commit d7d596bf4bddecdaaca03c95d4e38c89da205b41
Showing with 8 additions and 8 deletions.
  1. +2 −2 bchain/coins/blockchain.go
  2. +3 −3 db/sync.go
  3. +2 −2 server/socketio.go
  4. +1 −1 server/websocket.go
@@ -152,7 +152,7 @@ type blockChainWithMetrics struct {
func (c *blockChainWithMetrics) observeRPCLatency(method string, start time.Time, err error) { func (c *blockChainWithMetrics) observeRPCLatency(method string, start time.Time, err error) {
var e string var e string
if err != nil { 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 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) { func (c *mempoolWithMetrics) observeRPCLatency(method string, start time.Time, err error) {
var e string var e string
if err != nil { 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 c.m.RPCLatency.With(common.Labels{"method": method, "error": e}).Observe(float64(time.Since(start)) / 1e6) // in milliseconds
} }
@@ -78,7 +78,7 @@ func (w *SyncWorker) ResyncIndex(onNewBlock bchain.OnNewBlockFunc, initialSync b
return nil return nil
} }


w.metrics.IndexResyncErrors.With(common.Labels{"error": err.Error()}).Inc() w.metrics.IndexResyncErrors.With(common.Labels{"error": "failure"}).Inc()


return err return err
} }
@@ -300,7 +300,7 @@ func (w *SyncWorker) ConnectBlocksParallel(lower, higher uint32) error {
return return
} }
glog.Error("getBlockWorker ", i, " connect block error ", err, ". Retrying...") 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) time.Sleep(time.Millisecond * 500)
} else { } else {
break break
@@ -338,7 +338,7 @@ ConnectLoop:
hash, err = w.chain.GetBlockHash(h) hash, err = w.chain.GetBlockHash(h)
if err != nil { if err != nil {
glog.Error("GetBlockHash error ", err) 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) time.Sleep(time.Millisecond * 500)
continue continue
} }
@@ -185,7 +185,7 @@ func (s *SocketIoServer) onMessage(c *gosocketio.Channel, req map[string]json.Ra
return rv return rv
} }
glog.Error(c.Id(), " onMessage ", method, ": ", errors.ErrorStack(err)) 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 := resultError{}
e.Error.Message = err.Error() e.Error.Message = err.Error()
return e return e
@@ -670,7 +670,7 @@ func (s *SocketIoServer) onSubscribe(c *gosocketio.Channel, req []byte) interfac


onError := func(id, sc, err, detail string) { onError := func(id, sc, err, detail string) {
glog.Error(id, " onSubscribe ", err, ": ", detail) 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) r := string(req)
@@ -341,7 +341,7 @@ func (s *WebsocketServer) onRequest(c *websocketChannel, req *websocketReq) {
s.metrics.WebsocketRequests.With(common.Labels{"method": req.Method, "status": "success"}).Inc() s.metrics.WebsocketRequests.With(common.Labels{"method": req.Method, "status": "success"}).Inc()
} else { } else {
glog.Error("Client ", c.id, " onMessage ", req.Method, ": ", errors.ErrorStack(err)) 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 := resultError{}
e.Error.Message = err.Error() e.Error.Message = err.Error()
data = e data = e

0 comments on commit d7d596b

Please sign in to comment.
You can’t perform that action at this time.