Skip to content

Commit

Permalink
Retry on telemetry error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Jan 17, 2025
1 parent 9adfd8b commit f541aca
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import time

from counterpartycore.lib import config
from counterpartycore.lib.monitors.telemetry.clients.influxdb import TelemetryClientInfluxDB
Expand All @@ -17,14 +18,25 @@ def __init__(self):
logger.debug("Initializing TelemetryOneShot")
self.client = TelemetryClientInfluxDB()

def send(self, data, retry=0):
try:
self.client.send(data)
except Exception as e:

Check warning

Code scanning / pylint

Catching too general exception Exception. Warning

Catching too general exception Exception.
if retry < 10:
logger.trace(f"Error in telemetry one shot: {e}. Retrying in 2 seconds...")
time.sleep(2)
self.send(data, retry=retry + 1)
else:
raise e

def submit(self):
try:
with LedgerDBConnectionPool().connection() as ledger_db:
collector = TelemetryCollectorInfluxDB(db=ledger_db)
data = collector.collect()
collector.close()
if data:
self.client.send(data)
self.send(data)
except Exception as e:
capture_exception(e)
logger.warning(f"Error in telemetry one shot: {e}")

0 comments on commit f541aca

Please sign in to comment.