elstat.adapters: only log on errors

always logging was giving quite the disk usage on prod.
This commit is contained in:
Luna Mendes 2018-09-25 18:22:11 -03:00
parent 9f5d42c89c
commit 867d7d1e69

View file

@ -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
if not succ:
# only log on errors
worker.log.info(f'status={resp.status} latency={latency}ms')
if not succ:
# 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)