33import asyncio
44from helpers import strip_url
55from collectors .ws import websocket_collector
6-
6+ from websockets . exceptions import WebSocketException
77
88class 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