Skip to content

Commit 149a07e

Browse files
authored
Merge branch 'main' into version-bump
2 parents ad094dc + d219775 commit 149a07e

4 files changed

Lines changed: 655 additions & 829 deletions

File tree

scripts/generator-adapter/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,9 @@ latest-version@^9.0.0:
827827
package-json "^10.0.0"
828828

829829
lodash-es@^4.17.21:
830-
version "4.17.21"
831-
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
832-
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==
830+
version "4.17.23"
831+
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.23.tgz#58c4360fd1b5d33afc6c0bbd3d1149349b1138e0"
832+
integrity sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==
833833

834834
log-symbols@^7.0.0:
835835
version "7.0.0"

src/metrics/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,9 @@ export const metrics = new Metrics(() => ({
357357
help: 'The number of addresses in PoR request input parameters',
358358
labelNames: ['feed_id'] as const,
359359
}),
360+
wsConnectionFailoverCount: new client.Gauge({
361+
name: 'ws_connection_failover_count',
362+
help: 'The number of consecutive unresponsive connection detections (no data for WS_SUBSCRIPTION_UNRESPONSIVE_TTL), used to trigger URL failover',
363+
labelNames: ['transport_name', 'url'] as const,
364+
}),
360365
}))

src/transports/websocket.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)