summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorelukey <ltoscano@wikimedia.org>2017-07-24 15:20:17 +0200
committerelukey <ltoscano@wikimedia.org>2017-07-24 15:20:17 +0200
commit19dddafb75e10e10431f9caad068b64bcced4160 (patch)
treec1b5b98854118453fa0e47a9bdc6e6fac47fc4a7
parent5083e6b1e643e447cbbdacdd6e24455e44ef7195 (diff)
downloadlogster-19dddafb75e10e10431f9caad068b64bcced4160.zip
logster-19dddafb75e10e10431f9caad068b64bcced4160.tar.gz
logster-19dddafb75e10e10431f9caad068b64bcced4160.tar.bz2
Reduce DNS lookups for the statsd domain
The sendto socket call is very flexible but it currently issue a DNS lookup for the statsd domain for every metric in the for loop to push. This change ensures that only one lookup is performed for each batch of metrics to send. It is particularly useful when logster runs every minute and the number of metrics to push is very high.
-rw-r--r--logster/outputs/statsd.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/logster/outputs/statsd.py b/logster/outputs/statsd.py
index 3243133..0153850 100644
--- a/logster/outputs/statsd.py
+++ b/logster/outputs/statsd.py
@@ -23,6 +23,7 @@ class StatsdOutput(LogsterOutput):
def submit(self, metrics):
if (not self.dry_run):
host = self.statsd_host.split(':')
+ host[0] = socket.gethostbyname(host[0])
for metric in metrics:
metric_name = self.get_metric_name(metric)