Skip to content

Commit 966fe79

Browse files
authored
Bugfix/evm catch websocket exceptions (#11)
* Fix Solana healthcheck * Catch websocket exceptions for EVM collector since client does not.
1 parent 4a1d0da commit 966fe79

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/collectors/evm.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import asyncio
44
from helpers import strip_url
55
from collectors.ws import websocket_collector
6-
6+
from websockets.exceptions import WebSocketException
77

88
class evm_collector():
99

@@ -27,7 +27,7 @@ def __init__(self, websocket_url, https_url, provider):
2727
self.ws_collector.setDaemon(True)
2828
self.ws_collector.start()
2929

30-
def probe(self, metrics):
30+
def probe(self, metrics):
3131
try:
3232
if self.client.isConnected():
3333
metrics['ws_rpc_health'].add_metric(self.labels_values, True)
@@ -45,8 +45,12 @@ def probe(self, metrics):
4545
else:
4646
logger.info("Client is not connected to {}".format(strip_url(self.websocket_url)))
4747
metrics['ws_rpc_health'].add_metric(self.labels_values, False)
48-
except asyncio.exceptions.TimeoutError:
49-
logger.info("Client timed out for {}".format(strip_url(self.websocket_url)))
48+
except asyncio.exceptions.TimeoutError as exc:
49+
logger.info("Client timed out for {}: {}".format(strip_url(self.websocket_url), exc))
50+
metrics['ws_rpc_health'].add_metric(self.labels_values, False)
51+
except WebSocketException as exc:
52+
logger.info("Websocket client exception {}: {}".format(strip_url(self.websocket_url), exc))
5053
metrics['ws_rpc_health'].add_metric(self.labels_values, False)
5154
except Exception as exc:
5255
logger.error("Failed probing {} with error: {}".format(strip_url(self.url), exc))
56+
metrics['ws_rpc_health'].add_metric(self.labels_values, False)

0 commit comments

Comments
 (0)