Merge lp:~sidnei/txstatsd/preserve-last-gauge into lp:txstatsd

Proposed by Sidnei da Silva
Status: Merged
Approved by: Sidnei da Silva
Approved revision: 109
Merged at revision: 109
Proposed branch: lp:~sidnei/txstatsd/preserve-last-gauge
Merge into: lp:txstatsd
Diff against target: 42 lines (+10/-4)
2 files modified
txstatsd/server/processor.py (+0/-3)
txstatsd/tests/test_processor.py (+10/-1)
To merge this branch: bzr merge lp:~sidnei/txstatsd/preserve-last-gauge
Reviewer Review Type Date Requested Status
Sidnei da Silva Approve
Review via email: mp+191293@code.launchpad.net

Commit message

[a=bicycleday] Preserve gauges after each flush.

If the gauge is not updated at the next flush, it will send the
previous value. This is the definition of a gauge as per Etsy StatsD.
Also updated test_flush_gauge_metric in test_processor.py.

Description of the change

Preserve gauges after each flush.

If the gauge is not updated at the next flush, it will send the
previous value. This is the definition of a gauge as per Etsy StatsD.
Also updated test_flush_gauge_metric in test_processor.py.

To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'txstatsd/server/processor.py'
--- txstatsd/server/processor.py 2013-06-07 21:25:55 +0000
+++ txstatsd/server/processor.py 2013-10-15 20:59:48 +0000
@@ -25,7 +25,6 @@
25import logging25import logging
2626
27from twisted.python import log27from twisted.python import log
28from twisted.internet.task import Cooperator
2928
30from txstatsd.metrics.metermetric import MeterMetricReporter29from txstatsd.metrics.metermetric import MeterMetricReporter
3130
@@ -331,8 +330,6 @@
331330
332 yield ((self.gauge_prefix + key + ".value", value, timestamp),)331 yield ((self.gauge_prefix + key + ".value", value, timestamp),)
333332
334 self.gauge_metrics.clear()
335
336 def flush_meter_metrics(self, timestamp):333 def flush_meter_metrics(self, timestamp):
337 for metric in self.meter_metrics.itervalues():334 for metric in self.meter_metrics.itervalues():
338 messages = metric.report(timestamp)335 messages = metric.report(timestamp)
339336
=== modified file 'txstatsd/tests/test_processor.py'
--- txstatsd/tests/test_processor.py 2013-06-07 21:25:55 +0000
+++ txstatsd/tests/test_processor.py 2013-10-15 20:59:48 +0000
@@ -339,7 +339,16 @@
339 ("stats.gauge.gorets.value", 9.6, 42), messages[0])339 ("stats.gauge.gorets.value", 9.6, 42), messages[0])
340 self.assertEqual(340 self.assertEqual(
341 ("statsd.numStats", 1, 42), messages[1])341 ("statsd.numStats", 1, 42), messages[1])
342 self.assertEqual(0, len(self.processor.gauge_metrics))342
343 # ensure the gauge value remains after the flush.
344 self.assertEqual(1, len(self.processor.gauge_metrics))
345
346 # ensure that subsequent flushes continue to report the gauge value
347 messages = list(self.processor.flush())
348 self.assertEqual(
349 ("stats.gauge.gorets.value", 9.6, 42), messages[0])
350 self.assertEqual(
351 ("statsd.numStats", 1, 42), messages[1])
343352
344 def test_flush_distinct_metric(self):353 def test_flush_distinct_metric(self):
345 """354 """

Subscribers

People subscribed via source and target branches