From 59e1e09bd6e710d67e7e187d3ed6be1632ef4d72 Mon Sep 17 00:00:00 2001 From: Jiakan Wang Date: Wed, 18 May 2022 11:32:47 -0700 Subject: [PATCH 1/2] reduce log error with network exceptions --- statsig/statsig_network.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/statsig/statsig_network.py b/statsig/statsig_network.py index 4273f34..8760bcb 100644 --- a/statsig/statsig_network.py +++ b/statsig/statsig_network.py @@ -42,7 +42,7 @@ def post_request(self, endpoint, payload): else: return None except Exception as e: - self.__log.exception('Request to %s failed', endpoint) + self.__log.warning('Request to %s failed', endpoint) return None def retryable_request(self, endpoint, payload): @@ -61,10 +61,11 @@ def retryable_request(self, endpoint, payload): if response.status_code in self.__RETRY_CODES: return payload elif response.status_code >= 300: - self.__log.error("Request to %s failed with code %d", endpoint, response.status_code) + self.__log.error("Request to %s failed with code %d", + endpoint, response.status_code) return None - except Exception as e: - self.__log.exception("Request to %s failed", endpoint) + except Exception: + self.__log.warning("Request to %s failed", endpoint) return None def get_request(self, url, headers): @@ -78,6 +79,6 @@ def get_request(self, url, headers): return response else: return None - except: - self.__log.exception('Request to %s failed', url) + except Exception: + self.__log.warning('Request to %s failed', url) return None From 511fe14f7243706a16dce36af880c321cdd976e7 Mon Sep 17 00:00:00 2001 From: Jiakan Wang Date: Wed, 18 May 2022 11:37:15 -0700 Subject: [PATCH 2/2] feedback --- statsig/statsig_network.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/statsig/statsig_network.py b/statsig/statsig_network.py index 8760bcb..50b4dc3 100644 --- a/statsig/statsig_network.py +++ b/statsig/statsig_network.py @@ -42,7 +42,8 @@ def post_request(self, endpoint, payload): else: return None except Exception as e: - self.__log.warning('Request to %s failed', endpoint) + self.__log.warning( + 'Network exception caught when making request to %s failed', endpoint) return None def retryable_request(self, endpoint, payload): @@ -61,11 +62,12 @@ def retryable_request(self, endpoint, payload): if response.status_code in self.__RETRY_CODES: return payload elif response.status_code >= 300: - self.__log.error("Request to %s failed with code %d", - endpoint, response.status_code) + self.__log.warning( + "Request to %s failed with code %d", endpoint, response.status_code) return None except Exception: - self.__log.warning("Request to %s failed", endpoint) + self.__log.warning( + "Network exception caught when making request to %s failed", endpoint) return None def get_request(self, url, headers): @@ -80,5 +82,6 @@ def get_request(self, url, headers): else: return None except Exception: - self.__log.warning('Request to %s failed', url) + self.__log.warning( + 'Network exception caught when making request to %s failed', url) return None