send_analytics_to_remote_server: Log connection errors with traceback.

It seems helpful for this to get logged with the traceback rather than
just the general
"<exception name>  while trying to connect to push notification bouncer."
This commit is contained in:
Mateusz Mandera
2022-08-31 19:30:31 +02:00
committed by Alex Vandiver
parent 55c0a15f1c
commit cdd01b9f8e
2 changed files with 5 additions and 6 deletions

View File

@@ -161,7 +161,7 @@ def send_analytics_to_remote_server() -> None:
try:
result = send_to_push_bouncer("GET", "server/analytics/status", {})
except PushNotificationBouncerRetryLaterError as e:
logging.warning(e.msg)
logging.warning(e.msg, exc_info=True)
return
last_acked_realm_count_id = result["last_realm_count_id"]

View File

@@ -571,13 +571,12 @@ class AnalyticsBouncerTest(BouncerTestCase):
user = self.example_user("hamlet")
end_time = self.TIME_ZERO
with responses.RequestsMock() as resp, mock.patch(
"zerver.lib.remote_server.logging.warning"
) as mock_warning:
with responses.RequestsMock() as resp, self.assertLogs(level="WARNING") as mock_warning:
resp.add(responses.GET, ANALYTICS_STATUS_URL, body=ConnectionError())
send_analytics_to_remote_server()
mock_warning.assert_called_once_with(
"ConnectionError while trying to connect to push notification bouncer"
self.assertIn(
"WARNING:root:ConnectionError while trying to connect to push notification bouncer\nTraceback ",
mock_warning.output[0],
)
self.assertTrue(resp.assert_call_count(ANALYTICS_STATUS_URL, 1))