diff --git a/counterparty-core/counterpartycore/lib/monitors/telemetry/oneshot.py b/counterparty-core/counterpartycore/lib/monitors/telemetry/oneshot.py index 45c5f0419..9eefbeacc 100644 --- a/counterparty-core/counterpartycore/lib/monitors/telemetry/oneshot.py +++ b/counterparty-core/counterpartycore/lib/monitors/telemetry/oneshot.py @@ -1,4 +1,5 @@ import logging +import time from counterpartycore.lib import config from counterpartycore.lib.monitors.telemetry.clients.influxdb import TelemetryClientInfluxDB @@ -17,6 +18,17 @@ 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: + 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: @@ -24,7 +36,7 @@ def submit(self): 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}")