From 550c375abc6539ba373564a3e808042fec811a47 Mon Sep 17 00:00:00 2001 From: vakaris_zilius Date: Fri, 30 Sep 2022 09:54:12 +0000 Subject: [PATCH] Agent: Fix exception handling for failed delivery of agent events If there's an exception while sending the event to the island it should be logged as exception, not warning (events are not being stored, that's a big no-no). Also, the log should contain proper information of stack trace, not event type --- monkey/infection_monkey/agent_event_forwarder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/agent_event_forwarder.py b/monkey/infection_monkey/agent_event_forwarder.py index f253255d3..cf585a4bb 100644 --- a/monkey/infection_monkey/agent_event_forwarder.py +++ b/monkey/infection_monkey/agent_event_forwarder.py @@ -79,8 +79,8 @@ class BatchingAgentEventForwarder: try: logger.debug(f"Sending Agent events to Island: {events}") self._island_api_client.send_events(events) - except Exception as err: - logger.warning(f"Exception caught when connecting to the Island: {err}") + except Exception: + logger.exception("Exception caught when connecting to the Island") def _send_remaining_events(self): self._send_events_to_island()