Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc/metrics: Add support for libp2p-gossipsub #2277

Closed
wants to merge 1 commit into from

Conversation

mxinden
Copy link
Member

@mxinden mxinden commented Oct 6, 2021

A draft adding minimal support for libp2p-gossipsub to libp2p-metrics.

I think a first version should at least instrument all variants of GossipsubEvent.

/// Event that can be emitted by the gossipsub behaviour.
#[derive(Debug)]
pub enum GossipsubEvent {
/// A message has been received.
Message {
/// The peer that forwarded us this message.
propagation_source: PeerId,
/// The [`MessageId`] of the message. This should be referenced by the application when
/// validating a message (if required).
message_id: MessageId,
/// The decompressed message itself.
message: GossipsubMessage,
},
/// A remote subscribed to a topic.
Subscribed {
/// Remote that has subscribed.
peer_id: PeerId,
/// The topic it has subscribed to.
topic: TopicHash,
},
/// A remote unsubscribed from a topic.
Unsubscribed {
/// Remote that has unsubscribed.
peer_id: PeerId,
/// The topic it has subscribed from.
topic: TopicHash,
},
/// A peer that does not support gossipsub has connected.
GossipsubNotSupported { peer_id: PeerId },
}

In the long run we should extend GossipsubEvent to e.g. expose details about the mesh.

Example on how to use libp2p-metrics can be found here: https://github.com/libp2p/rust-libp2p/blob/master/misc/metrics/examples/metrics.rs

A binary using libp2p-metrics is e.g. https://github.com/mxinden/rust-libp2p-server/

@mxinden mxinden added difficulty:easy help wanted getting-started Issues that can be tackled if you don't know the internals of libp2p very well labels Oct 6, 2021
@mxinden
Copy link
Member Author

mxinden commented Dec 29, 2021

Merged via #2316.

@mxinden mxinden closed this Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:easy getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant