From a6a8afac3905d03f31483206783a4ca5e5c3001f Mon Sep 17 00:00:00 2001 From: Avinash Vishwakarma <43632198+avinashdunzo@users.noreply.github.com> Date: Wed, 26 May 2021 15:42:00 +0530 Subject: [PATCH 01/11] introducing circuit breaker within library (#1) introducing circuit breaker within library --- requests/__version__.py | 2 +- requests/api.py | 10 +++ requests/circuit_breaker.py | 171 ++++++++++++++++++++++++++++++++++++ requests/exceptions.py | 11 +++ requirements.txt | 2 + 5 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 requests/circuit_breaker.py diff --git a/requests/__version__.py b/requests/__version__.py index dc33eef651..ffc10af842 100644 --- a/requests/__version__.py +++ b/requests/__version__.py @@ -5,7 +5,7 @@ __title__ = 'requests' __description__ = 'Python HTTP for Humans.' __url__ = 'http://python-requests.org' -__version__ = '2.18.4' +__version__ = '2.18.4-cb' __build__ = 0x021804 __author__ = 'Kenneth Reitz' __author_email__ = 'me@kennethreitz.org' diff --git a/requests/api.py b/requests/api.py index bc2115c150..415066402a 100644 --- a/requests/api.py +++ b/requests/api.py @@ -11,6 +11,7 @@ """ from . import sessions +from .circuit_breaker import default_circuit_breaker def request(method, url, **kwargs): @@ -54,6 +55,15 @@ def request(method, url, **kwargs): # By using the 'with' statement we are sure the session is closed, thus we # avoid leaving sockets open which can trigger a ResourceWarning in some # cases, and look like a memory leak in others. + + executed, response = default_circuit_breaker.execute_with_circuit_breaker(basic_request, method, url, **kwargs) + if executed: + return response + + return basic_request(method, url, **kwargs) + + +def basic_request(method, url, **kwargs): with sessions.Session() as session: return session.request(method=method, url=url, **kwargs) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py new file mode 100644 index 0000000000..2a3a481800 --- /dev/null +++ b/requests/circuit_breaker.py @@ -0,0 +1,171 @@ +import pybreaker +import os +import json +import warnings +from urllib3.util.url import get_host +from .exceptions import ApiCircuitBreakerError, CustomHttpCircuitBreakerError +import newrelic.agent +import socket + + +class MonitorListener(pybreaker.CircuitBreakerListener): + + def __init__(self): + self.ip = None + self.app_name = None + try: + self.ip = socket.gethostbyname(socket.gethostname()) + self.app_name = newrelic.core.config.global_settings().app_name + except: + pass + + def failure(self, cb, exc): + self.send_updates(cb, 0, 1) + + def success(self, cb): + self.send_updates(cb, 1, 0) + + def state_change(self, cb, old_state, new_state): + self.send_updates(cb, 0, 0) + + def send_updates(self, cb, success_count, fail_count): + try: + newrelic.agent.record_custom_event("circuit_breaker_event_espresso", { + + "name": cb.name, + "service_name": self.app_name, + "instance_ip": self.ip, + "circuit_state": cb.current_state, + "success": success_count, + "errors": fail_count, + "fallback_success": 0, + "fallback_failure": 0, + }, newrelic.agent.application()) + except: + pass + + +class CircuitBreakerConfig(object): + + def __init__(self, fail_max_to_open, sleep_time_to_half_open, http_failed_status_code_list, + http_method_keyword_params): + self.fail_max_to_open = fail_max_to_open + self.sleep_time_to_half_open = sleep_time_to_half_open + self.http_failed_status_code_list = http_failed_status_code_list or [] + self.http_method_keyword_params = http_method_keyword_params or [] + + @staticmethod + def from_json(json_data): + configs = {} + try: + for config in json_data: + try: + if config["domain_name"] in configs: + warnings.warn( + "Config already present once overriding :" + config["domain_name"]) + http_method_keyword_params = config.get("http_method_keyword_params") or [] + http_method_keyword_params = list(filter(lambda x: (x.get('keyword') and x.get('method')), + http_method_keyword_params)) + configs[config["domain_name"]] = CircuitBreakerConfig(config["fail_max_to_open"], + config["sleep_time_to_half_open"], + config["http_failed_status_code_list"], + http_method_keyword_params) + except: + warnings.warn("JSON File has wrong format circuit breaker functionality wont be used :" + config) + except: + warnings.warn("JSON File has wrong format circuit breaker functionality wont be used : JSON_PARSE_ERROR") + return configs + + +class CircuitBreaker(object): + + def __init__(self): + self.__circuit_breaker_factory_per_domain = {} + self.__circuit_breaker_config_per_domain = {} + self.__load_from_json_file() + self.__register_circuit_breaker() + + def __load_from_json_file(self): + + json_file_path = os.environ.get("CB_JSON_FILE_PATH") or None + if not json_file_path: + warnings.warn("JSON File path not found circuit breaker functionality wont be used : JSON_FILE_PATH") + try: + with open(json_file_path, ) as f: + data = json.load(f) + self.__circuit_breaker_config_per_domain = CircuitBreakerConfig.from_json(data) + except: + warnings.warn("JSON File has wrong format circuit breaker functionality wont be used : JSON_FILE_PATH") + + def __register_circuit_breaker(self): + + try: + for key, config in self.__circuit_breaker_config_per_domain.iteritems(): + + if not config.http_method_keyword_params: + self.__circuit_breaker_factory_per_domain[key] = pybreaker.CircuitBreaker( + fail_max=config.fail_max_to_open, + reset_timeout=config.sleep_time_to_half_open, + state_storage=pybreaker.CircuitMemoryStorage(pybreaker.STATE_CLOSED), name=key, + listeners=[MonitorListener()]) + else: + for param in config.http_method_keyword_params: + k = CircuitBreaker.__get_domain_key(key, param) + self.__circuit_breaker_factory_per_domain[k] = pybreaker.CircuitBreaker( + fail_max=config.fail_max_to_open, + reset_timeout=config.sleep_time_to_half_open, + state_storage=pybreaker.CircuitMemoryStorage(pybreaker.STATE_CLOSED), name=k, + listeners=[MonitorListener()]) + except: + pass + + @staticmethod + def __get_domain_key(domain_name, param): + return "{}_{}_{}".format(domain_name, param["keyword"], param["method"]) + + def __get_circuit_breaker_by_url(self, url, method): + try: + _, domain_name, port = get_host(url) + if port not in [80, 443]: + domain_name = "{}:{}".format(domain_name, port) + cfg = self.__circuit_breaker_config_per_domain.get(domain_name) + + if not cfg.http_method_keyword_params: + return self.__circuit_breaker_factory_per_domain.get(domain_name), cfg.http_failed_status_code_list + + for param in cfg.http_method_keyword_params: + if param["keyword"] in url and param["method"] == method: + cb = self.__circuit_breaker_config_per_domain.get(CircuitBreaker.__get_domain_key(domain_name, param)) + if cb: + return cb, cfg.http_failed_status_code_list + + except Exception as e: + warnings.warn("error while getting url: {}".format(e.message)) + pass + + return None, None + + def execute_with_circuit_breaker(self, func, method, url, **kwargs): + + cb, status_code_list = self.__get_circuit_breaker_by_url(url, method) + if not cb: + return False, None + + try: + return True, cb.call(CircuitBreaker.basic_request_cb, status_code_list, func, method, url, **kwargs) + except pybreaker.CircuitBreakerError: + raise ApiCircuitBreakerError( + "Requests are closed because of too many failures".format(url) + ) + except CustomHttpCircuitBreakerError as e: + return True, e.http_response + + @staticmethod + def basic_request_cb(status_code_list, func, method, url, **kwargs): + response = func(method, url, **kwargs) + if response.status_code in status_code_list: + raise CustomHttpCircuitBreakerError(response) + return response + + +default_circuit_breaker = CircuitBreaker() diff --git a/requests/exceptions.py b/requests/exceptions.py index be7eaed6b9..7753f6beea 100644 --- a/requests/exceptions.py +++ b/requests/exceptions.py @@ -104,6 +104,17 @@ class RetryError(RequestException): class UnrewindableBodyError(RequestException): """Requests encountered an error when trying to rewind a body""" + +class ApiCircuitBreakerError(RequestException): + """Requests encountered as circuit was open """ + + +class CustomHttpCircuitBreakerError(Exception): + """Failure in http status codes """ + def __init__(self, http_response): + super(CustomHttpCircuitBreakerError, self).__init__() + self.http_response = http_response + # Warnings diff --git a/requirements.txt b/requirements.txt index 8d79283fd9..c218499e5c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,3 +14,5 @@ docutils flake8 tox detox +pybreaker==0.6.0 +newrelic==4.2.0.100 From 92c7c53381322ed0a8b1ae84a0f4272833493d21 Mon Sep 17 00:00:00 2001 From: Avinash Vishwakarma <43632198+avinashdunzo@users.noreply.github.com> Date: Wed, 26 May 2021 15:50:40 +0530 Subject: [PATCH 02/11] Update __version__.py --- requests/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/__version__.py b/requests/__version__.py index ffc10af842..536d3825b9 100644 --- a/requests/__version__.py +++ b/requests/__version__.py @@ -5,7 +5,7 @@ __title__ = 'requests' __description__ = 'Python HTTP for Humans.' __url__ = 'http://python-requests.org' -__version__ = '2.18.4-cb' +__version__ = '2.18.50' __build__ = 0x021804 __author__ = 'Kenneth Reitz' __author_email__ = 'me@kennethreitz.org' From 1e5ad92bf305481e1ccddcec334d195c78b32697 Mon Sep 17 00:00:00 2001 From: Manish Date: Wed, 26 May 2021 16:32:02 +0530 Subject: [PATCH 03/11] add env name in evetn type --- requests/circuit_breaker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 2a3a481800..13b039ce88 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -11,6 +11,7 @@ class MonitorListener(pybreaker.CircuitBreakerListener): def __init__(self): + self.event_name = "circuit_breaker_event_espresso_{}".format(os.getenv('ENV')) self.ip = None self.app_name = None try: @@ -30,7 +31,7 @@ def state_change(self, cb, old_state, new_state): def send_updates(self, cb, success_count, fail_count): try: - newrelic.agent.record_custom_event("circuit_breaker_event_espresso", { + newrelic.agent.record_custom_event(self.event_name, { "name": cb.name, "service_name": self.app_name, From c88c6628c15330718d03c71d124e917d91e4e618 Mon Sep 17 00:00:00 2001 From: Manish Date: Thu, 27 May 2021 12:31:17 +0530 Subject: [PATCH 04/11] add logs --- requests/circuit_breaker.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 13b039ce88..9c084fbd73 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -18,6 +18,7 @@ def __init__(self): self.ip = socket.gethostbyname(socket.gethostname()) self.app_name = newrelic.core.config.global_settings().app_name except: + warnings.warn("error init MonitorListener event_name: {}".format(self.event_name)) pass def failure(self, cb, exc): @@ -31,6 +32,7 @@ def state_change(self, cb, old_state, new_state): def send_updates(self, cb, success_count, fail_count): try: + warnings.warn("inside send_updates event_name: {}".format(self.event_name)) newrelic.agent.record_custom_event(self.event_name, { "name": cb.name, @@ -43,6 +45,7 @@ def send_updates(self, cb, success_count, fail_count): "fallback_failure": 0, }, newrelic.agent.application()) except: + warnings.warn("error send_updates for event_name: {}".format(self.event_name)) pass @@ -150,6 +153,7 @@ def execute_with_circuit_breaker(self, func, method, url, **kwargs): cb, status_code_list = self.__get_circuit_breaker_by_url(url, method) if not cb: + warnings.warn("error execute_with_circuit_breaker cb not found: {}".format(url)) return False, None try: From 258865749ff493b4b8fef0a466ac600b6e046cc8 Mon Sep 17 00:00:00 2001 From: Manish Date: Thu, 27 May 2021 13:40:20 +0530 Subject: [PATCH 05/11] add logs --- requests/circuit_breaker.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 9c084fbd73..3a0429ac1f 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -1,7 +1,7 @@ import pybreaker import os import json -import warnings +import logging from urllib3.util.url import get_host from .exceptions import ApiCircuitBreakerError, CustomHttpCircuitBreakerError import newrelic.agent @@ -18,7 +18,7 @@ def __init__(self): self.ip = socket.gethostbyname(socket.gethostname()) self.app_name = newrelic.core.config.global_settings().app_name except: - warnings.warn("error init MonitorListener event_name: {}".format(self.event_name)) + logging.exception("error init MonitorListener event_name: {}".format(self.event_name)) pass def failure(self, cb, exc): @@ -32,7 +32,7 @@ def state_change(self, cb, old_state, new_state): def send_updates(self, cb, success_count, fail_count): try: - warnings.warn("inside send_updates event_name: {}".format(self.event_name)) + logging.info("inside send_updates event_name: {} {}".format(self.event_name, os.getenv('ENV'))) newrelic.agent.record_custom_event(self.event_name, { "name": cb.name, @@ -45,7 +45,7 @@ def send_updates(self, cb, success_count, fail_count): "fallback_failure": 0, }, newrelic.agent.application()) except: - warnings.warn("error send_updates for event_name: {}".format(self.event_name)) + logging.exception("error send_updates for event_name: {}".format(self.event_name)) pass @@ -65,7 +65,7 @@ def from_json(json_data): for config in json_data: try: if config["domain_name"] in configs: - warnings.warn( + logging.exception( "Config already present once overriding :" + config["domain_name"]) http_method_keyword_params = config.get("http_method_keyword_params") or [] http_method_keyword_params = list(filter(lambda x: (x.get('keyword') and x.get('method')), @@ -75,9 +75,9 @@ def from_json(json_data): config["http_failed_status_code_list"], http_method_keyword_params) except: - warnings.warn("JSON File has wrong format circuit breaker functionality wont be used :" + config) + logging.exception("JSON File has wrong format circuit breaker functionality wont be used :" + config) except: - warnings.warn("JSON File has wrong format circuit breaker functionality wont be used : JSON_PARSE_ERROR") + logging.exception("JSON File has wrong format circuit breaker functionality wont be used : JSON_PARSE_ERROR") return configs @@ -93,13 +93,13 @@ def __load_from_json_file(self): json_file_path = os.environ.get("CB_JSON_FILE_PATH") or None if not json_file_path: - warnings.warn("JSON File path not found circuit breaker functionality wont be used : JSON_FILE_PATH") + logging.exception("JSON File path not found circuit breaker functionality wont be used : JSON_FILE_PATH") try: with open(json_file_path, ) as f: data = json.load(f) self.__circuit_breaker_config_per_domain = CircuitBreakerConfig.from_json(data) except: - warnings.warn("JSON File has wrong format circuit breaker functionality wont be used : JSON_FILE_PATH") + logging.exception("JSON File has wrong format circuit breaker functionality wont be used : JSON_FILE_PATH") def __register_circuit_breaker(self): @@ -130,7 +130,7 @@ def __get_domain_key(domain_name, param): def __get_circuit_breaker_by_url(self, url, method): try: _, domain_name, port = get_host(url) - if port not in [80, 443]: + if port not in [80, 443, None]: domain_name = "{}:{}".format(domain_name, port) cfg = self.__circuit_breaker_config_per_domain.get(domain_name) @@ -144,7 +144,7 @@ def __get_circuit_breaker_by_url(self, url, method): return cb, cfg.http_failed_status_code_list except Exception as e: - warnings.warn("error while getting url: {}".format(e.message)) + logging.exception("error while getting url: {}".format(e.message)) pass return None, None @@ -153,7 +153,7 @@ def execute_with_circuit_breaker(self, func, method, url, **kwargs): cb, status_code_list = self.__get_circuit_breaker_by_url(url, method) if not cb: - warnings.warn("error execute_with_circuit_breaker cb not found: {}".format(url)) + logging.exception("error execute_with_circuit_breaker cb not found: {}".format(url)) return False, None try: From deecf53e18e16a7e885852c9dc6c54f513b0e259 Mon Sep 17 00:00:00 2001 From: Manish Date: Fri, 28 May 2021 12:27:01 +0530 Subject: [PATCH 06/11] refactor --- requests/circuit_breaker.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 3a0429ac1f..39a70f1509 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -65,7 +65,7 @@ def from_json(json_data): for config in json_data: try: if config["domain_name"] in configs: - logging.exception( + logging.error( "Config already present once overriding :" + config["domain_name"]) http_method_keyword_params = config.get("http_method_keyword_params") or [] http_method_keyword_params = list(filter(lambda x: (x.get('keyword') and x.get('method')), @@ -95,32 +95,33 @@ def __load_from_json_file(self): if not json_file_path: logging.exception("JSON File path not found circuit breaker functionality wont be used : JSON_FILE_PATH") try: - with open(json_file_path, ) as f: + with open(json_file_path, "r") as f: data = json.load(f) self.__circuit_breaker_config_per_domain = CircuitBreakerConfig.from_json(data) except: logging.exception("JSON File has wrong format circuit breaker functionality wont be used : JSON_FILE_PATH") + def __update_cb_factory(self, key, config): + self.__circuit_breaker_factory_per_domain[key] = pybreaker.CircuitBreaker( + fail_max=config.fail_max_to_open, + reset_timeout=config.sleep_time_to_half_open, + state_storage=pybreaker.CircuitMemoryStorage(pybreaker.STATE_CLOSED), name=key, + listeners=[MonitorListener()] + ) + def __register_circuit_breaker(self): try: for key, config in self.__circuit_breaker_config_per_domain.iteritems(): if not config.http_method_keyword_params: - self.__circuit_breaker_factory_per_domain[key] = pybreaker.CircuitBreaker( - fail_max=config.fail_max_to_open, - reset_timeout=config.sleep_time_to_half_open, - state_storage=pybreaker.CircuitMemoryStorage(pybreaker.STATE_CLOSED), name=key, - listeners=[MonitorListener()]) + self.__update_cb_factory(key, config) else: for param in config.http_method_keyword_params: - k = CircuitBreaker.__get_domain_key(key, param) - self.__circuit_breaker_factory_per_domain[k] = pybreaker.CircuitBreaker( - fail_max=config.fail_max_to_open, - reset_timeout=config.sleep_time_to_half_open, - state_storage=pybreaker.CircuitMemoryStorage(pybreaker.STATE_CLOSED), name=k, - listeners=[MonitorListener()]) + k = self.__get_domain_key(key, param) + self.__update_cb_factory(k, config) except: + logging.exception("error registering circuit breaker") pass @staticmethod @@ -134,6 +135,8 @@ def __get_circuit_breaker_by_url(self, url, method): domain_name = "{}:{}".format(domain_name, port) cfg = self.__circuit_breaker_config_per_domain.get(domain_name) + if cfg is None: + return None, None if not cfg.http_method_keyword_params: return self.__circuit_breaker_factory_per_domain.get(domain_name), cfg.http_failed_status_code_list From d418fa5a5c177b850e250a1562927c23da77146c Mon Sep 17 00:00:00 2001 From: Manish Date: Fri, 28 May 2021 12:31:20 +0530 Subject: [PATCH 07/11] refactor --- requests/circuit_breaker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 39a70f1509..768d4631aa 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -15,8 +15,8 @@ def __init__(self): self.ip = None self.app_name = None try: - self.ip = socket.gethostbyname(socket.gethostname()) self.app_name = newrelic.core.config.global_settings().app_name + self.ip = socket.gethostbyname(socket.gethostname()) except: logging.exception("error init MonitorListener event_name: {}".format(self.event_name)) pass From 1db7a4d4c5c32a7ffc6076ff33fe06befbaa4963 Mon Sep 17 00:00:00 2001 From: Manish Date: Fri, 28 May 2021 16:47:34 +0530 Subject: [PATCH 08/11] refactor --- requests/circuit_breaker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 768d4631aa..4a4d34d27d 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -88,6 +88,7 @@ def __init__(self): self.__circuit_breaker_config_per_domain = {} self.__load_from_json_file() self.__register_circuit_breaker() + self.metric_collector = MonitorListener() def __load_from_json_file(self): @@ -106,7 +107,7 @@ def __update_cb_factory(self, key, config): fail_max=config.fail_max_to_open, reset_timeout=config.sleep_time_to_half_open, state_storage=pybreaker.CircuitMemoryStorage(pybreaker.STATE_CLOSED), name=key, - listeners=[MonitorListener()] + listeners=[self.metric_collector] ) def __register_circuit_breaker(self): From 8a9ed783f7259b41a11396ab5d132e3c6f05f119 Mon Sep 17 00:00:00 2001 From: Manish Date: Fri, 28 May 2021 19:16:04 +0530 Subject: [PATCH 09/11] dunzo_branch-mmaks requsts --- requests/circuit_breaker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 4a4d34d27d..1d3746fd0f 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -84,11 +84,11 @@ def from_json(json_data): class CircuitBreaker(object): def __init__(self): + self.metric_collector = MonitorListener() self.__circuit_breaker_factory_per_domain = {} self.__circuit_breaker_config_per_domain = {} self.__load_from_json_file() self.__register_circuit_breaker() - self.metric_collector = MonitorListener() def __load_from_json_file(self): From 69a47d3fc6ffa33af66ad3d21ba45d7a258be16e Mon Sep 17 00:00:00 2001 From: avinash Date: Tue, 1 Jun 2021 11:53:42 +0530 Subject: [PATCH 10/11] adding dependency --- requests/__version__.py | 2 +- setup.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requests/__version__.py b/requests/__version__.py index 536d3825b9..60847245ff 100644 --- a/requests/__version__.py +++ b/requests/__version__.py @@ -5,7 +5,7 @@ __title__ = 'requests' __description__ = 'Python HTTP for Humans.' __url__ = 'http://python-requests.org' -__version__ = '2.18.50' +__version__ = '2.18.51' __build__ = 0x021804 __author__ = 'Kenneth Reitz' __author_email__ = 'me@kennethreitz.org' diff --git a/setup.py b/setup.py index ed4892d41f..ce176533c4 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,9 @@ def run_tests(self): 'chardet>=3.0.2,<3.1.0', 'idna>=2.5,<2.7', 'urllib3>=1.21.1,<1.23', - 'certifi>=2017.4.17' + 'certifi>=2017.4.17', + 'pybreaker==0.6.0', + 'newrelic==4.2.0.100' ] test_requirements = ['pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock', 'pytest-xdist', 'PySocks>=1.5.6, !=1.5.7', 'pytest>=2.8.0'] From 852693ce947292b871c12d1f1114cf6fb0e74d43 Mon Sep 17 00:00:00 2001 From: Manish Date: Tue, 1 Jun 2021 12:06:37 +0530 Subject: [PATCH 11/11] remove ogger --- requests/circuit_breaker.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requests/circuit_breaker.py b/requests/circuit_breaker.py index 1d3746fd0f..b75d47e93f 100644 --- a/requests/circuit_breaker.py +++ b/requests/circuit_breaker.py @@ -32,7 +32,6 @@ def state_change(self, cb, old_state, new_state): def send_updates(self, cb, success_count, fail_count): try: - logging.info("inside send_updates event_name: {} {}".format(self.event_name, os.getenv('ENV'))) newrelic.agent.record_custom_event(self.event_name, { "name": cb.name, @@ -157,7 +156,7 @@ def execute_with_circuit_breaker(self, func, method, url, **kwargs): cb, status_code_list = self.__get_circuit_breaker_by_url(url, method) if not cb: - logging.exception("error execute_with_circuit_breaker cb not found: {}".format(url)) + # logging.exception("error execute_with_circuit_breaker cb not found: {}".format(url)) return False, None try: