Merge lp:~lifeless/python-oops-tools/amqp into lp:python-oops-tools

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: 5
Merged at revision: 4
Proposed branch: lp:~lifeless/python-oops-tools/amqp
Merge into: lp:python-oops-tools
Diff against target: 65 lines (+20/-3)
2 files modified
src/oopstools/NEWS.txt (+6/-0)
src/oopstools/scripts/amqp2disk.py (+14/-3)
To merge this branch: bzr merge lp:~lifeless/python-oops-tools/amqp
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+79749@code.launchpad.net

Commit message

Update the amqp support to be a little easier to use and more robust.

Description of the change

Update the amqp support to be a little easier to use and more robust. Also working properly. (I've had a dev environment doing just-in-time reporting of OOPSes! \o/).

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/oopstools/NEWS.txt'
2--- src/oopstools/NEWS.txt 2011-10-18 04:15:08 +0000
3+++ src/oopstools/NEWS.txt 2011-10-18 23:10:28 +0000
4@@ -9,6 +9,12 @@
5
6 * Bumped oops-amqp rev to 0.0.2 for bugfixes. (Robert Collins)
7
8+* amqp2disk now creates a fanout exchange if --bind-to is supplied.
9+ (Robert Collins)
10+
11+* amqp2disk -v will print the received OOPS ids on the console, for
12+ entertainment and delight. (Robert Collins)
13+
14 0.6
15 ===
16
17
18=== modified file 'src/oopstools/scripts/amqp2disk.py'
19--- src/oopstools/scripts/amqp2disk.py 2011-10-18 04:15:08 +0000
20+++ src/oopstools/scripts/amqp2disk.py 2011-10-18 23:10:28 +0000
21@@ -55,9 +55,12 @@
22 The AMQP environment should be setup in advance with a persistent queue
23 bound to your exchange : using transient queues would allow OOPSes to
24 be lost if the amqp2disk process were to be shutdown for a non-trivial
25- duration. The --bind-to option will cause the queue to be created and
26- bound to the given exchange. This is only needed the first time as it
27- is created persistently.
28+ duration. The --bind-to option will cause the queue (and exchange if
29+ necessary) to be created and bound together. This is only needed the
30+ first time as it is created persistently. Running it when the exchange
31+ already exists (to setup a second worker, or because you manually
32+ created it with a different setup) is fine. The default setup is a
33+ fanout exchange.
34 """)
35 description = "Load OOPS reports into oops-tools from AMQP."
36 parser = optparse.OptionParser(
37@@ -70,6 +73,8 @@
38 parser.add_option('--queue', help="AMQP queue name.")
39 parser.add_option(
40 '--bind-to', help="AMQP exchange to bind to (only needed once).")
41+ parser.add_option("-v", "--verbose", action="store_true",
42+ help="Print more information about what is going on.")
43 options, args = parser.parse_args(argv[1:])
44 def needed(optname):
45 if getattr(options, optname, None) is None:
46@@ -88,6 +93,8 @@
47 try:
48 channel = connection.channel()
49 try:
50+ channel.exchange_declare(
51+ options.bind_to, type="fanout", durable=True, auto_delete=False)
52 channel.queue_declare(
53 options.queue, durable=True, auto_delete=False)
54 channel.queue_bind(options.queue, options.bind_to)
55@@ -96,6 +103,10 @@
56 finally:
57 connection.close()
58 config = make_amqp_config(options.output)
59+ if options.verbose:
60+ def print_oops(report):
61+ print ("Received %s" % report['id'])
62+ config.publishers.append(print_oops)
63 receiver = oops_amqp.Receiver(config, factory, options.queue)
64 try:
65 receiver.run_forever()

Subscribers

People subscribed via source and target branches

to all changes: