@@ -414,9 +414,16 @@ export class WebSocketTransport<
414414 // to determine minimum TTL of an open connection given no explicit connection errors.
415415 if ( connectionUnresponsive ) {
416416 this . streamHandlerInvocationsWithNoConnection += 1
417- logger . trace (
418- `The connection is unresponsive, incremented streamHandlerIterationsWithNoConnection = ${ this . streamHandlerInvocationsWithNoConnection } ` ,
417+ logger . info (
418+ `The connection is unresponsive (last message ${ timeSinceLastMessage } ms ago) , incremented failover counter to ${ this . streamHandlerInvocationsWithNoConnection } ` ,
419419 )
420+ // Filter out query params from the URL to avoid leaking sensitive data
421+ // and prevent metric cardinality explosion
422+ const filteredUrl = this . currentUrl . split ( '?' ) [ 0 ]
423+ metrics
424+ . get ( 'wsConnectionFailoverCount' )
425+ . labels ( { transport_name : this . name , url : filteredUrl } )
426+ . set ( this . streamHandlerInvocationsWithNoConnection )
420427 }
421428
422429 // We want to check if the URL we calculate is different from the one currently connected.
@@ -431,10 +438,9 @@ export class WebSocketTransport<
431438 // Check if we should close the current connection
432439 if ( ! connectionClosed && ( urlChanged || connectionUnresponsive ) ) {
433440 if ( urlChanged ) {
441+ logger . info ( 'Websocket URL has changed, closing connection to reconnect...' )
434442 censorLogs ( ( ) =>
435- logger . debug (
436- `Websocket url has changed from ${ this . currentUrl } to ${ urlFromConfig } , closing connection...` ,
437- ) ,
443+ logger . debug ( `Websocket URL changed from ${ this . currentUrl } to ${ urlFromConfig } ` ) ,
438444 )
439445 } else {
440446 censorLogs ( ( ) =>
0 commit comments