Add metrics for mailserver errors (#1242)

This commit is contained in:
Andrea Franz 2018-10-16 17:24:37 +02:00 committed by Ivan Daniluk
parent e7c588fcd0
commit b9baa48d87
1 changed files with 15 additions and 8 deletions

View File

@ -56,6 +56,9 @@ var (
archivedMeter = metrics.NewRegisteredMeter("mailserver/archivedEnvelopes", nil)
archivedSizeMeter = metrics.NewRegisteredMeter("mailserver/archivedEnvelopesSize", nil)
archivedErrorsCounter = metrics.NewRegisteredCounter("mailserver/archiveErrors", nil)
requestValidationErrorsCounter = metrics.NewRegisteredCounter("mailserver/requestValidationErrors", nil)
processRequestErrorsCounter = metrics.NewRegisteredCounter("mailserver/processRequestErrors", nil)
historicResponseErrorsCounter = metrics.NewRegisteredCounter("mailserver/historicResponseErrors", nil)
)
const (
@ -252,13 +255,17 @@ func (s *WMailServer) DeliverMail(peer *whisper.Peer, request *whisper.Envelope)
if ok, lower, upper, bloom, limit, cursor := s.validateRequest(peer.ID(), request); ok {
_, lastEnvelopeHash, nextPageCursor, err := s.processRequest(peer, lower, upper, bloom, limit, cursor)
if err != nil {
processRequestErrorsCounter.Inc(1)
log.Error(fmt.Sprintf("error in DeliverMail: %s", err))
return
}
if err := s.sendHistoricMessageResponse(peer, request, lastEnvelopeHash, nextPageCursor); err != nil {
historicResponseErrorsCounter.Inc(1)
log.Error(fmt.Sprintf("SendHistoricMessageResponse error: %s", err))
}
} else {
requestValidationErrorsCounter.Inc(1)
}
}