Skip to content

Commit

Permalink
adjust debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
yimuniao committed Jul 25, 2017
1 parent 68dae62 commit b3c828b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/cloudwatch/modules/client/putclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,19 @@ def __init__(self, config_helper, connection_timeout=_DEFAULT_CONNECTION_TIMEOUT
self.debug = config_helper.debug
self.config = config_helper
self._prepare_session()
if config_helper.debug:
if config_helper.proxy_server_name is not None:
self._LOGGER.info("Using proxy server: " + config_helper.proxy_server_name)
if config_helper.proxy_server_port is not None:
self._LOGGER.info("Using proxy server port: " + config_helper.proxy_server_port)
else:
self._LOGGER.info("No proxy server is in use")

def _prepare_session(self):
self.session = Session()
if self.proxy_server_name is not None:
proxy_server = self.proxy_server_name
self._LOGGER.info("Using proxy server: " + proxy_server)
if self.proxy_server_port is not None:
proxy_server = proxy_server + ":" + self.proxy_server_port
self._LOGGER.info("Using proxy server port: " + self.proxy_server_port)
proxies = {'https': proxy_server}
self.session.proxies.update(proxies)
else:
self._LOGGER.info("No proxy server is in use")
self.session.mount("http://", HTTPAdapter(max_retries=self._TOTAL_RETRIES))
self.session.mount("https://", HTTPAdapter(max_retries=self._TOTAL_RETRIES))

Expand Down
8 changes: 6 additions & 2 deletions src/cloudwatch/modules/flusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def _aggregate_metric(self, value_list):
nan_value_count = 0
dimension_key = self._get_metric_key(value_list)
adjusted_time = int(value_list.time)
if self.config.debug:
self._LOGGER.info("Received key"+dimension_key + " Adjusted_time: " + str(adjusted_time) + " Original time: " + str(value_list.time))

key = dimension_key
if self.enable_high_definition_metrics:
key = dimension_key + "-" + str(adjusted_time)
Expand All @@ -106,6 +105,11 @@ def _aggregate_metric(self, value_list):
nan_value_count = self._add_metric_to_queue(value_list, adjusted_time, key)
else:
if self.enable_high_definition_metrics:
if self.config.debug and self.metric_map:
state = ""
for dimension_metrics in self.metric_map:
state += str(dimension_metrics) + "[" + str(self.metric_map[dimension_metrics][0].statistics.sample_count) + "] "
self._LOGGER.info("[debug] flushing metrics " + state)
self._flush()
nan_value_count = self._add_metric_to_queue(value_list, adjusted_time, key)
else:
Expand Down

0 comments on commit b3c828b

Please sign in to comment.