Permalink
Browse files

Gauge should only report the current value

Need to write some proper unit tests.
  • Loading branch information...
1 parent a735e9a commit 537fe309a1642e4a2b10c2877ff22dafb3bd3155 @pandemicsyn committed Jul 13, 2012
Showing with 7 additions and 10 deletions.
  1. +5 −8 statsdpy/statsd.py
  2. +2 −2 utils/genevent.py
View
@@ -109,10 +109,9 @@ def stats_flush(self):
self.timers[key] = []
for key in self.gauges:
- if len(self.gauges[key]) > 0:
- payload.append("stats.gauges.%s %d %d\n" %
- (key, self.gauges[key], int(time.time())))
- self.gauges[key] = []
+ payload.append("stats.gauges.%s %d %d\n" %
+ (key, self.gauges[key], int(time.time())))
+ self.gauges[key] = "0"
if payload:
self.report_stats("".join(payload))
@@ -126,9 +125,7 @@ def process_gauge(self, key, fields):
:param fields: Received fields
"""
try:
- if key not in self.gauges:
- self.gauges[key] = []
- self.gauges[key].append(float(fields[0] or 0))
+ self.gauges[key] = float(fields[0])
if self.stats_seen >= maxint:
self.logger.info("hit maxint, reset seen counter")
self.stats_seen = 0
@@ -148,7 +145,7 @@ def process_timer(self, key, fields):
try:
if key not in self.timers:
self.timers[key] = []
- self.timers[key].append(float(fields[0] or 0))
+ self.timers[key].append(float(fields[0]))
if self.stats_seen >= maxint:
self.logger.info("hit maxint, reset seen counter")
self.stats_seen = 0
View
@@ -11,9 +11,9 @@ def send_event(payload):
combined_events = ["comb_testitem:1|c\nctest2:4|c", "ctimertest1:200|ms\nctestitem1:1|c|@0.5"]
transform_test = 'te$t_key !fix{\)\/?@#%th\'is^&*be"ok'
-good_events = ['testitem:1|c', 'testitem:1|c|@0.5','timertest:300|ms', 'timertest:400|ms', 'timertest:500|ms']
+good_events = ['gtest:100|g', 'gtest:99|g', 'testitem:1|c', 'testitem:1|c|@0.5','timertest:300|ms', 'timertest:400|ms', 'timertest:500|ms']
crap_events = ['.', ' ', ':', ' : |c', 'baditem:1|k', 'baditem:1|c|@',
- 'baditem:1|c|@wtf', 'baditem:1|c|@05f.6', 'badtimer:5.0f|ms']
+ 'baditem:1|c|@wtf', 'baditem:1|c|@05f.6', 'badtimer:5.0f|ms', 'badgauge:K|g']
def bench(payload, limit):
for i in xrange(1, limit):

0 comments on commit 537fe30

Please sign in to comment.