@@ -14,6 +14,10 @@ class Hub {
1414 this . logger = logger ;
1515 this . numClientAllWorkers = 0 ;
1616 this . numWorkers = 0 ;
17+ this . stats = {
18+ notFoundCount : 0 ,
19+ total : 1 ,
20+ } ;
1721 setInterval ( ( ) => {
1822 this . checkConns ( ) ;
1923 } , CHECK_CLIENT_INTERVAL * 1000 + randomNum ( 0 , 10000 ) )
@@ -238,6 +242,7 @@ class Hub {
238242 if ( data . candidate && ! data . candidate . candidate ) {
239243 return
240244 }
245+ this . stats . total ++ ;
241246 if ( target ) {
242247 const success = this . sendJsonToClient ( target , this . _processJson ( json , peerId , target . isCompact ) ) ;
243248 if ( ! success ) {
@@ -288,6 +293,7 @@ class Hub {
288293
289294 async _handlePeerNotFound ( client , toPeerId , peerId ) {
290295 // this.logger.info(`_handlePeerNotFound ${client} ${toPeerId} ${peerId}`);
296+ this . stats . notFoundCount ++ ;
291297 const msg = {
292298 action : 'signal' ,
293299 from_peer_id : toPeerId ,
@@ -335,9 +341,13 @@ class Hub {
335341 // if (wsCountRemoved > 0 || httpCountRemoved > 0) {
336342 // this.logger.warn(`check cmap finished, closed clients: ws ${wsCountRemoved} polling ${httpCountRemoved}`);
337343 // }
338- this . logger . warn ( `current clients ws ${ wsCount } , polling ${ httpCount } , hit cache ${ ( ( redis . stats . curCount / redis . stats . totalCount ) * 100 ) . toFixed ( 2 ) } %` ) ;
344+ this . logger . warn ( `current clients ws ${ wsCount } , polling ${ httpCount } , hit cache ${ ( ( redis . stats . curCount / redis . stats . totalCount ) * 100 ) . toFixed ( 2 ) } %, peerNotFound ${ ( ( this . stats . notFoundCount / this . stats . total ) * 100 ) . toFixed ( 2 ) } % ` ) ;
339345 redis . stats . curCount = 0 ;
340346 redis . stats . totalCount = 1 ;
347+ this . stats = {
348+ notFoundCount : 0 ,
349+ total : 1 ,
350+ }
341351 }
342352}
343353
0 commit comments