Merge "Convert haproxy-statsd to a pipeline send"

This commit is contained in:
Zuul 2018-06-12 02:11:49 +00:00 committed by Gerrit Code Review
commit 9c3bbdcdb3

@ -145,12 +145,13 @@ class HAProxy(object):
return ret
def reportStats(self, stats):
pipe = statsd.pipeline()
for row in stats:
base = 'haproxy.%s.%s.' % (row['pxname'], row['svname'])
for key in GAUGES:
value = row[key]
if value != '':
statsd.gauge(base + key, int(value))
pipe.gauge(base + key, int(value))
for key in COUNTERS:
metric = base + key
newvalue = row[key]
@ -160,8 +161,9 @@ class HAProxy(object):
oldvalue = self.prevdata.get(metric)
if oldvalue is not None:
value = newvalue - oldvalue
statsd.incr(metric, value)
pipe.incr(metric, value)
self.prevdata[metric] = newvalue
pipe.send()
def run(self):
while True: