p2p: add catchall dialOtherError meter

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-04-15 01:46:07 +02:00
parent fd020d92f0
commit 7e1e26c9b0
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -59,10 +59,16 @@ var (
dialUnexpectedIdentity = metrics.NewRegisteredMeter("p2p/dials/error/id/unexpected", nil) dialUnexpectedIdentity = metrics.NewRegisteredMeter("p2p/dials/error/id/unexpected", nil)
dialEncHandshakeError = metrics.NewRegisteredMeter("p2p/dials/error/rlpx/enc", nil) dialEncHandshakeError = metrics.NewRegisteredMeter("p2p/dials/error/rlpx/enc", nil)
dialProtoHandshakeError = metrics.NewRegisteredMeter("p2p/dials/error/rlpx/proto", nil) dialProtoHandshakeError = metrics.NewRegisteredMeter("p2p/dials/error/rlpx/proto", nil)
// capure the rest of errors that are not handled by the above meters
dialOtherError = metrics.NewRegisteredMeter("p2p/dials/error/other", nil)
) )
// markDialError matches errors that occur while setting up a dial connection // markDialError matches errors that occur while setting up a dial connection
// to the corresponding meter. // to the corresponding meter.
// markDialError will bump exactly one meter per call. We don't maintain meters
// for evert possible error. If there are multiple levels of wrapped errors, we
// capture the innermost for which we have a meter.
func markDialError(err error) { func markDialError(err error) {
if !metrics.Enabled() { if !metrics.Enabled() {
return return
@ -84,6 +90,10 @@ func markDialError(err error) {
dialEncHandshakeError.Mark(1) dialEncHandshakeError.Mark(1)
case errors.As(err, &phe): case errors.As(err, &phe):
dialProtoHandshakeError.Mark(1) dialProtoHandshakeError.Mark(1)
default:
// catch all for any other error, not supposed to happen, only here for cross-checking
// that all errors are captured by the above meters
dialOtherError.Mark(1)
} }
} }