From 867d7d1e6930c3072ad9c6a0feddd256d05b32e0 Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Tue, 25 Sep 2018 18:22:11 -0300 Subject: [PATCH] elstat.adapters: only log on errors always logging was giving quite the disk usage on prod. --- elstat/adapters.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/elstat/adapters.py b/elstat/adapters.py index dceb16d..812aa7b 100644 --- a/elstat/adapters.py +++ b/elstat/adapters.py @@ -66,12 +66,13 @@ class PingAdapter(Adapter): else: latency = 0 - worker.log.info(f'alive={alive} latency={latency}ms') - if alive: # we dont need to keep sending err_msg on alive scenarios return cls._construct(alive, latency) + # only log on errors + worker.log.info(f'alive={alive} latency={latency}ms') + err = PING_ERROR_RGX.search(out) err_msg = err.group(2) if not alive and err else 'packet lost' @@ -110,9 +111,11 @@ class HttpAdapter(Adapter): # drop latency to 0 to signal a non-success latency = latency if succ else 0 - worker.log.info(f'status={resp.status} latency={latency}ms') - if not succ: + # only log on errors + worker.log.info(f'status={resp.status} latency={latency}ms') + + # construct error message from http error code status_phrase = cls.get_phrase(resp.status) err_str = f'http status {resp.status} - {status_phrase}' return cls._construct(succ, latency, err_str)