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

Proposed by Sidnei da Silva on 2013-10-15
Status: Merged
Approved by: Sidnei da Silva on 2013-10-15
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 on 2013-10-15
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.
Sidnei da Silva (sidnei) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txstatsd/server/processor.py'
2--- txstatsd/server/processor.py 2013-06-07 21:25:55 +0000
3+++ txstatsd/server/processor.py 2013-10-15 20:59:48 +0000
4@@ -25,7 +25,6 @@
5 import logging
6
7 from twisted.python import log
8-from twisted.internet.task import Cooperator
9
10 from txstatsd.metrics.metermetric import MeterMetricReporter
11
12@@ -331,8 +330,6 @@
13
14 yield ((self.gauge_prefix + key + ".value", value, timestamp),)
15
16- self.gauge_metrics.clear()
17-
18 def flush_meter_metrics(self, timestamp):
19 for metric in self.meter_metrics.itervalues():
20 messages = metric.report(timestamp)
21
22=== modified file 'txstatsd/tests/test_processor.py'
23--- txstatsd/tests/test_processor.py 2013-06-07 21:25:55 +0000
24+++ txstatsd/tests/test_processor.py 2013-10-15 20:59:48 +0000
25@@ -339,7 +339,16 @@
26 ("stats.gauge.gorets.value", 9.6, 42), messages[0])
27 self.assertEqual(
28 ("statsd.numStats", 1, 42), messages[1])
29- self.assertEqual(0, len(self.processor.gauge_metrics))
30+
31+ # ensure the gauge value remains after the flush.
32+ self.assertEqual(1, len(self.processor.gauge_metrics))
33+
34+ # ensure that subsequent flushes continue to report the gauge value
35+ messages = list(self.processor.flush())
36+ self.assertEqual(
37+ ("stats.gauge.gorets.value", 9.6, 42), messages[0])
38+ self.assertEqual(
39+ ("statsd.numStats", 1, 42), messages[1])
40
41 def test_flush_distinct_metric(self):
42 """

Subscribers

People subscribed via source and target branches