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

@ -48,14 +48,17 @@ var (
errDecryptionMethodNotProvided = errors.New("decryption method is not provided") errDecryptionMethodNotProvided = errors.New("decryption method is not provided")
// By default go-ethereum/metrics creates dummy metrics that don't register anything. // By default go-ethereum/metrics creates dummy metrics that don't register anything.
// Real metrics are collected only if -metrics flag is set // Real metrics are collected only if -metrics flag is set
requestProcessTimer = metrics.NewRegisteredTimer("mailserver/requestProcessTime", nil) requestProcessTimer = metrics.NewRegisteredTimer("mailserver/requestProcessTime", nil)
requestsMeter = metrics.NewRegisteredMeter("mailserver/requests", nil) requestsMeter = metrics.NewRegisteredMeter("mailserver/requests", nil)
requestErrorsCounter = metrics.NewRegisteredCounter("mailserver/requestErrors", nil) requestErrorsCounter = metrics.NewRegisteredCounter("mailserver/requestErrors", nil)
sentEnvelopesMeter = metrics.NewRegisteredMeter("mailserver/sentEnvelopes", nil) sentEnvelopesMeter = metrics.NewRegisteredMeter("mailserver/sentEnvelopes", nil)
sentEnvelopesSizeMeter = metrics.NewRegisteredMeter("mailserver/sentEnvelopesSize", nil) sentEnvelopesSizeMeter = metrics.NewRegisteredMeter("mailserver/sentEnvelopesSize", nil)
archivedMeter = metrics.NewRegisteredMeter("mailserver/archivedEnvelopes", nil) archivedMeter = metrics.NewRegisteredMeter("mailserver/archivedEnvelopes", nil)
archivedSizeMeter = metrics.NewRegisteredMeter("mailserver/archivedEnvelopesSize", nil) archivedSizeMeter = metrics.NewRegisteredMeter("mailserver/archivedEnvelopesSize", nil)
archivedErrorsCounter = metrics.NewRegisteredCounter("mailserver/archiveErrors", 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 ( 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 { if ok, lower, upper, bloom, limit, cursor := s.validateRequest(peer.ID(), request); ok {
_, lastEnvelopeHash, nextPageCursor, err := s.processRequest(peer, lower, upper, bloom, limit, cursor) _, lastEnvelopeHash, nextPageCursor, err := s.processRequest(peer, lower, upper, bloom, limit, cursor)
if err != nil { if err != nil {
processRequestErrorsCounter.Inc(1)
log.Error(fmt.Sprintf("error in DeliverMail: %s", err)) log.Error(fmt.Sprintf("error in DeliverMail: %s", err))
return return
} }
if err := s.sendHistoricMessageResponse(peer, request, lastEnvelopeHash, nextPageCursor); err != nil { if err := s.sendHistoricMessageResponse(peer, request, lastEnvelopeHash, nextPageCursor); err != nil {
historicResponseErrorsCounter.Inc(1)
log.Error(fmt.Sprintf("SendHistoricMessageResponse error: %s", err)) log.Error(fmt.Sprintf("SendHistoricMessageResponse error: %s", err))
} }
} else {
requestValidationErrorsCounter.Inc(1)
} }
} }