fix log mangling, make event queue 10x bigger to avoid dropping logs

This commit is contained in:
gmega 2024-12-09 10:59:09 -03:00
parent 39d72e71b3
commit e6aa22dbbb
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
2 changed files with 4 additions and 1 deletions

View File

@ -41,7 +41,7 @@ class AlertManager(component.Component):
self.session = component.get('Core').session self.session = component.get('Core').session
# Increase the alert queue size so that alerts don't get lost. # Increase the alert queue size so that alerts don't get lost.
self.alert_queue_size = 10000 self.alert_queue_size = 1000000
self.set_alert_queue_size(self.alert_queue_size) self.set_alert_queue_size(self.alert_queue_size)
alert_mask = ( alert_mask = (

View File

@ -27,6 +27,7 @@ class Metrics:
fieldnames=['metric', 'timestamp', 'labels', 'value'], fieldnames=['metric', 'timestamp', 'labels', 'value'],
) )
self.log_writer.writeheader() self.log_writer.writeheader()
self._flush_to_log()
core.session.post_dht_stats() core.session.post_dht_stats()
def handle_alert(self, alert): def handle_alert(self, alert):
@ -57,7 +58,9 @@ class Metrics:
'value': alert.piece_index, 'value': alert.piece_index,
}) })
) )
self._flush_to_log()
def _flush_to_log(self):
logger.info(self._buffer.getvalue()) logger.info(self._buffer.getvalue())
self._buffer.truncate(0) self._buffer.truncate(0)
self._buffer.seek(0) self._buffer.seek(0)