From 7e1e26c9b04a779ddb97279d91039a7f1dee575a Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 15 Apr 2025 01:46:07 +0200 Subject: [PATCH] p2p: add catchall dialOtherError meter Signed-off-by: Csaba Kiraly --- p2p/metrics.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/p2p/metrics.go b/p2p/metrics.go index 21e3cac520..d3c61c4f34 100644 --- a/p2p/metrics.go +++ b/p2p/metrics.go @@ -59,10 +59,16 @@ var ( dialUnexpectedIdentity = metrics.NewRegisteredMeter("p2p/dials/error/id/unexpected", nil) dialEncHandshakeError = metrics.NewRegisteredMeter("p2p/dials/error/rlpx/enc", 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 // 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) { if !metrics.Enabled() { return @@ -84,6 +90,10 @@ func markDialError(err error) { dialEncHandshakeError.Mark(1) case errors.As(err, &phe): 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) } }