Merge lp:~theiw/txstatsd/txstatsd-fix-871735 into lp:txstatsd

Proposed by Ian Wilkinson
Status: Merged
Approved by: Ian Wilkinson
Approved revision: 43
Merged at revision: 43
Proposed branch: lp:~theiw/txstatsd/txstatsd-fix-871735
Merge into: lp:txstatsd
Diff against target: 84 lines (+20/-4)
4 files modified
txstatsd/server/configurableprocessor.py (+12/-0)
txstatsd/server/processor.py (+4/-1)
txstatsd/tests/test_configurableprocessor.py (+3/-2)
txstatsd/version.py (+1/-1)
To merge this branch: bzr merge lp:~theiw/txstatsd/txstatsd-fix-871735
Reviewer Review Type Date Requested Status
Sidnei da Silva Approve
Review via email: mp+78867@code.launchpad.net

Commit message

Ensure the prefix is applied to the metrics summary.

Description of the change

Ensure the prefix is applied to the metrics summary.

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

Looks good. +1!

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 2011-10-01 04:05:34 +0000
3+++ txstatsd/server/configurableprocessor.py 2011-10-10 16:12:32 +0000
4@@ -22,10 +22,19 @@
5 duration statistics, plus throughput statistics.
6 """
7
8+ METRICS_SUMMARY = "statsd.numStats %s %s\n"
9+
10 def __init__(self, time_function=time.time, message_prefix=""):
11 super(ConfigurableMessageProcessor, self).__init__(
12 time_function=time_function)
13
14+ if message_prefix:
15+ self.metrics_summary = message_prefix + '.' + \
16+ ConfigurableMessageProcessor.METRICS_SUMMARY
17+ else:
18+ self.metrics_summary = \
19+ ConfigurableMessageProcessor.METRICS_SUMMARY
20+
21 self.message_prefix = message_prefix
22 self.gauge_metrics = {}
23
24@@ -92,6 +101,9 @@
25
26 return (metrics, events)
27
28+ def flush_metrics_summary(self, messages, num_stats, timestamp):
29+ messages.append(self.metrics_summary % (num_stats, timestamp))
30+
31 def update_metrics(self):
32 super(ConfigurableMessageProcessor, self).update_metrics()
33
34
35=== modified file 'txstatsd/server/processor.py'
36--- txstatsd/server/processor.py 2011-10-07 19:44:10 +0000
37+++ txstatsd/server/processor.py 2011-10-10 16:12:32 +0000
38@@ -192,7 +192,7 @@
39 messages.extend(meter_metrics)
40 num_stats += events
41
42- messages.append("statsd.numStats %s %s\n" % (num_stats, timestamp))
43+ self.flush_metrics_summary(messages, num_stats, timestamp)
44 return messages
45
46 def flush_counter_metrics(self, interval, timestamp):
47@@ -278,6 +278,9 @@
48
49 return (metrics, events)
50
51+ def flush_metrics_summary(self, messages, num_stats, timestamp):
52+ messages.append("statsd.numStats %s %s\n" % (num_stats, timestamp))
53+
54 def update_metrics(self):
55 for metric in self.meter_metrics.itervalues():
56 metric.tick()
57
58=== modified file 'txstatsd/tests/test_configurableprocessor.py'
59--- txstatsd/tests/test_configurableprocessor.py 2011-10-07 19:49:25 +0000
60+++ txstatsd/tests/test_configurableprocessor.py 2011-10-10 16:12:32 +0000
61@@ -34,7 +34,8 @@
62 self.assertEqual(2, len(messages))
63 counters = messages[0].splitlines()
64 self.assertEqual("test.metric.gorets.count 17 42", counters[0])
65- self.assertEqual("statsd.numStats 1 42", messages[1].splitlines()[0])
66+ self.assertEqual("test.metric.statsd.numStats 1 42",
67+ messages[1].splitlines()[0])
68
69 def test_flush_single_timer_single_time(self):
70 """
71@@ -138,5 +139,5 @@
72 "test.metric.gorets.15min_rate 0.0 %s" % self.time_now,
73 meter_metric[4])
74 self.assertEqual(
75- "statsd.numStats 1 %s" % self.time_now,
76+ "test.metric.statsd.numStats 1 %s" % self.time_now,
77 messages[1].splitlines()[0])
78
79=== modified file 'txstatsd/version.py'
80--- txstatsd/version.py 2011-10-01 04:05:34 +0000
81+++ txstatsd/version.py 2011-10-10 16:12:32 +0000
82@@ -1,1 +1,1 @@
83-txstatsd = "0.6.0"
84+txstatsd = "0.6.2"

Subscribers

People subscribed via source and target branches