libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.
https://libp2p.io
MIT License
4.52k stars 936 forks source link

feat(metrics): Extend `IncomingConnectionError::TransportErrorOther` #3680

Open mxinden opened 1 year ago

mxinden commented 1 year ago

Description

Is there an elegant way to expose more information than IncomingConnectionError::TransportErrorOther on transport specific errors without depending on concrete types?

We could use std::any::type_name.

Motivation

It would be good to know why in particular incoming connections on the Kademlia Exporter fail. See e.g. Incoming error per second graph.

https://github.com/libp2p/rust-libp2p/blob/1a85e24ef94eba2a79104d13e89b0891bf5997d4/misc/metrics/src/swarm.rs#L361-L370

thomaseizinger commented 1 year ago

TransportError::Other is an io::Error. You could display the io::Error kind.

Alternatively, you could capture richer information in the first place and create more variants for the errors you'd like to see.