From 65b08a9807a233bc8630f6ffec1f9e996a069c56 Mon Sep 17 00:00:00 2001 From: anton Date: Mon, 5 May 2014 19:57:36 +0400 Subject: [PATCH] correct gauge signature from statsd client version 2.0+ --- django_statsd/clients/log.py | 4 ++-- django_statsd/clients/toolbar.py | 7 +++++-- requirements.txt | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/django_statsd/clients/log.py b/django_statsd/clients/log.py index ad4e7da..4bc59c2 100644 --- a/django_statsd/clients/log.py +++ b/django_statsd/clients/log.py @@ -20,6 +20,6 @@ class StatsClient(StatsClient): """Decrement a stat by `count`.""" log.info('Decrement: %s, %s, %s' % (stat, count, rate)) - def gauge(self, stat, value, rate=1): + def gauge(self, stat, value, rate=1, delta=False): """Set a gauge value.""" - log.info('Gauge: %s, %s, %s' % (stat, value, rate)) + log.info('Gauge: %s, %s%s, %s' % (stat, '' if not delta else 'diff ', value , rate)) diff --git a/django_statsd/clients/toolbar.py b/django_statsd/clients/toolbar.py index 6fab61f..408d88e 100644 --- a/django_statsd/clients/toolbar.py +++ b/django_statsd/clients/toolbar.py @@ -31,10 +31,13 @@ class StatsClient(StatsClient): stat = '%s|count' % stat self.cache[stat].append([-count, rate]) - def gauge(self, stat, value, rate=1): + def gauge(self, stat, value, rate=1, delta=False): """Set a gauge value.""" stat = '%s|gauge' % stat - self.cache[stat] = [[value, rate]] + if delta: + self.cache[stat].append([value, rate]) + else: + self.cache[stat] = [[value, rate]] def set(self, stat, value, rate=1): stat = '%s|set' % stat diff --git a/requirements.txt b/requirements.txt index 52e6777..5cc8cfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ mock nose unittest2 -statsd==1.0.0 -django<1.5 +statsd>=2.0.0 +django<1.6