File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -698,7 +698,10 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements PubSub<G
698698 * Registrar notifies an established connection with pubsub protocol
699699 */
700700 private onPeerConnected ( peerId : PeerId , connection : Connection ) : void {
701- if ( ! this . isStarted ( ) ) {
701+ this . metrics ?. newConnectionCount . inc ( { status : connection . stat . status } )
702+ // libp2p may emit a closed connection and never issue peer:disconnect event
703+ // see https://github.com/ChainSafe/js-libp2p-gossipsub/issues/398
704+ if ( ! this . isStarted ( ) || connection . stat . status !== 'OPEN' ) {
702705 return
703706 }
704707
Original file line number Diff line number Diff line change @@ -512,6 +512,12 @@ export function getMetrics(
512512 help : 'Total count of key collisions on fastmsgid cache put'
513513 } ) ,
514514
515+ newConnectionCount : register . gauge < { status : string } > ( {
516+ name : 'gossipsub_new_connection_total' ,
517+ help : 'Total new connection by status' ,
518+ labelNames : [ 'status' ]
519+ } ) ,
520+
515521 topicStrToLabel : topicStrToLabel ,
516522
517523 toTopic ( topicStr : TopicStr ) : TopicLabel {
You can’t perform that action at this time.
0 commit comments