Permalink
Browse files

Count how frequently items are added to amqp.

  • Loading branch information...
1 parent 27cbadd commit d30b558931da474c5f06b7bbaae60cec34e43742 Logan Hanks committed with spladug Apr 25, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 r2/r2/lib/amqp.py
View
@@ -42,6 +42,7 @@
log = g.log
amqp_virtual_host = g.amqp_virtual_host
amqp_logging = g.amqp_logging
+stats = g.stats
#there are two ways of interacting with this module: add_item and
#handle_items/consume_items. _add_item (the internal function for
@@ -154,16 +155,20 @@ def _add_item(routing_key, body, message_id = None,
if message_id:
msg.properties['message_id'] = message_id
+ event_name = 'amqp.%s' % routing_key
try:
chan.basic_publish(msg,
exchange = amqp_exchange,
routing_key = routing_key)
except Exception as e:
+ stats.event_count(event_name, 'enqueue_failed')
if e.errno == errno.EPIPE:
connection_manager.get_channel(True)
add_item(routing_key, body, message_id)
else:
raise
+ else:
+ stats.event_count(event_name, 'enqueue')
def add_item(routing_key, body, message_id = None, delivery_mode = DELIVERY_DURABLE):
if amqp_host and amqp_logging:

0 comments on commit d30b558

Please sign in to comment.