Merge lp:~james-w/txstatsd/delta-configurable-processor into lp:txstatsd

Proposed by James Westby on 2014-10-16
Status: Merged
Approved by: Ricardo Kirkner on 2014-10-16
Approved revision: 112
Merged at revision: 111
Proposed branch: lp:~james-w/txstatsd/delta-configurable-processor
Merge into: lp:txstatsd
Diff against target: 43 lines (+20/-2)
2 files modified
txstatsd/server/configurableprocessor.py (+2/-2)
txstatsd/tests/test_configurableprocessor.py (+18/-0)
To merge this branch: bzr merge lp:~james-w/txstatsd/delta-configurable-processor
Reviewer Review Type Date Requested Status
Ricardo Kirkner (community) 2014-10-16 Approve on 2014-10-16
Review via email: mp+238546@code.launchpad.net

Commit message

Fix gauge delta support in ConfigurableMessageProcessor.

To post a comment you must log in.
112. By James Westby on 2014-10-16

Fix indentation.

Ricardo Kirkner (ricardokirkner) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txstatsd/server/configurableprocessor.py'
2--- txstatsd/server/configurableprocessor.py 2013-06-07 21:25:55 +0000
3+++ txstatsd/server/configurableprocessor.py 2014-10-16 11:29:36 +0000
4@@ -80,11 +80,11 @@
5 self.counter_metrics[key] = metric
6 self.counter_metrics[key].mark(value)
7
8- def compose_gauge_metric(self, key, value):
9+ def compose_gauge_metric(self, key, value, delta=False):
10 if not key in self.gauge_metrics:
11 metric = GaugeMetricReporter(key, prefix=self.message_prefix)
12 self.gauge_metrics[key] = metric
13- self.gauge_metrics[key].mark(value)
14+ self.gauge_metrics[key].mark(value, delta=delta)
15
16 def compose_meter_metric(self, key, value):
17 if not key in self.meter_metrics:
18
19=== modified file 'txstatsd/tests/test_configurableprocessor.py'
20--- txstatsd/tests/test_configurableprocessor.py 2013-06-07 21:25:55 +0000
21+++ txstatsd/tests/test_configurableprocessor.py 2014-10-16 11:29:36 +0000
22@@ -174,3 +174,21 @@
23 messages[0])
24 self.assertEqual(("test.metric.gorets.rate", 3.0, self.time_now),
25 messages[1])
26+
27+
28+class ComposeTests(TestCase):
29+
30+ def test_compose_gauge_metric(self):
31+ configurable_processor = ConfigurableMessageProcessor()
32+ configurable_processor.compose_gauge_metric('a', 1)
33+ self.assertEqual(
34+ configurable_processor.gauge_metrics['a'].value,
35+ 1)
36+
37+ def test_compose_gauge_metric_delta(self):
38+ configurable_processor = ConfigurableMessageProcessor()
39+ configurable_processor.compose_gauge_metric('a', 1)
40+ configurable_processor.compose_gauge_metric('a', 1, delta=True)
41+ self.assertEqual(
42+ configurable_processor.gauge_metrics['a'].value,
43+ 2)

Subscribers

People subscribed via source and target branches