LegNeato! Christian Legnitto's blog about Mozilla, Apple, technology, and random stuff

22Dec/10Off

Another update on Pulse

With Firefox 4 beta 8 and Firefox 4 beta 3 for mobile out (whew!) it's time to give an update on pulse.mozilla.org.

View Pulse messages live from your browser!

I set up a page to show the messages flowing through the system. You can view it at http://pulse.mozilla.org/live. The page makes for a nifty (barebones) status dashboard of work going on around Mozilla.

The technology behind the page is fairly interesting. I am using Node.js to connect to RabbitMQ via AMQP and serve the messages over Socket.io (which uses long polling or WebSockets) to client code served by Django via WSGI to the browser. That's a lot of alphabet soup but it was surprisingly easy to set up. It's pretty exciting and fun to use theĀ  cutting edge technologies everyone is talking about.

A future blog post will detail exactly what I did, but you can see the Node.js code at http://hg.mozilla.org/users/clegnitto_mozilla.com/pulsewebsite/file/default/node/browser_amqp.js. Simple yet powerful.

General

  • I no longer consider Pulse a prototype. I now consider it in beta and will be doing more evangelism to get people writing tools against the system. Geo in QA has a prototype system written against Pulse and has already suggested some great improvements
  • The system moved to a new, beefier VM in the Phoenix data center. Hopefully the days of running out of disk space and memory are over!
  • I have documented (with video!) how to go from our stock RHEL 5 VM image to a running Pulse instance. I will be writing it up and finishing up the video in the coming weeks

Website

  • The website is finally in Mercurial. It is basically the old static site stuck into a Django template, but at least it lays the groundwork for future work
  • Added the live view functionality as mentioned above

Scrapers

Messages

  • There is now a heartbeat message sent every minute. This message lets people playing around with the system know their code is working and makes it so the web view doesn't have periods of inactivity. To see the messages you can use "PulseTestConsumer" from the python helper library or you can connect to the "org.mozilla.exchange.pulse.test" exchange via a standard AMQP client. There may be other messages sent through that exchange, so if you want to only listen for the heartbeat messages listen for "heartbeat"
  • One of the RelEng buildbot masters is now publishing build messages into Pulse (see bug 614576). To see the messages you can use "BuildConsumer" from the python helper library or you can connect to the "org.mozilla.exchange.build" exchange via a standard AMQP client
  • James Socol and Jeff Balogh have set up some of their Mozilla GitHub repos to publish commit events into Pulse using the GitHub service hook I created. To see the messages you can use "CodeConsumer" from the python helper library or you can connect to the "org.mozilla.exchange.code" exchange via a standard AMQP client. To only listen to GitHub messages filter on "github.#". If you listen for "#" you will also get messages from Mozilla's Mercurial repositories

Code

  • The python helper library now defaults to temporary/non-durable queues. This should make experimentation easier for folks and will lessen the resource requirements on the server
  • The python helper library now specifies its requirements in such a way that easy_install and pip will automatically download necessary dependencies
  • I have started to put example code into Mercurial so new users don't need to copy and paste from the website. The repository is at http://hg.mozilla.org/users/clegnitto_mozilla.com/pulsequickstart/. I intend to expand it a fair amount, add other language examples, etc.

There is also exciting work going on to instrument assorted systems so I can retire the shim/scraper scripts. I'll likely have more to report about that in the coming weeks though.

If anyone has graphic skills and would like to help me out with the website, a logo, or create a cool dashboard using the data flowing though Pulse get in touch! I've been playing around with interesting ways to visualize the data and hope to have more to show in the coming quarter.

23Nov/10Off

GitHub AMQP integration service hook live!

As of last night you can now send AMQP messages to a message broker (like the one running on pulse.mozilla.org) for GitHub pushes and commits!

Here's how to set it up...

First, go to the admin area of one of your repositories:

Next click on "Service Hooks" on the left hand side:

After that, select the AMQP service hook:

Configure the hook to point at your server and it's done!

Once configured, the next time you push there will be messages sent via AMQP to your server from GitHub. Currently, it sends one overall push message containing all changeset info in the push as well as individual changeset messages.

Mesages are sent for the push with the following routing key format:

"github.push.#{owner}.#{repo}.#{ref}"

where:

owner = payload['repository']['owner']['name']
repo  = payload['repository']['name']
ref   = payload['ref_name']

Messages are also sent for each commit in a push, with the following routing key format:

"github.commit.#{owner}.#{repo}.#{ref}.#{author}"

where:

author = commit['author']['email']
(other fields are the same as above)

The message data is sent in JSON format.

Here's an example commit message (dumped from Python):

{u'_meta': {u'exchange': u'org.mozilla.exchange.pulse.test',
 u'routing_key': u'github.commit.LegNeato.bztools.master.clegnitto@mozilla.com'},
 u'payload': {u'author': {u'email': u'clegnitto@mozilla.com',
 u'name': u'Christian Legnitto',
 u'username': u'LegNeato'},
 u'files': {u'added': [],
 u'modified': [u'README.rst'],
 u'removed': []},
 u'id': u'4d69ae955e6f877000ecfe17def333b32973070b',
 u'message': u'Change readme to point to my repo (and a test of AMQP GitHub service hook)',
 u'timestamp': u'2010-11-22T15:16:26-08:00',
 u'url': u'https://github.com/LegNeato/bztools/commit/4d69ae955e6f877000ecfe17def333b32973070b'}}

And here's an example push message (dumped from Python):

{u'_meta': {u'exchange': u'org.mozilla.exchange.pulse.test',
 u'routing_key': u'github.push.LegNeato.bztools.master'},
 u'payload': {u'after': u'0ccf64aa593e96a19529b9c9a3b1e0098c626108',
 u'before': u'9aa20993159d5e714103abc6741b43feb371fc34',
 u'commits': [{u'author': {u'email': u'clegnitto@mozilla.com',
 u'name': u'Christian Legnitto',
 u'username': u'LegNeato'},
 u'files': {u'added': [],
 u'modified': [u'bugzilla/models.py'],
 u'removed': []},
 u'id': u'80539c359d22ca35f61c34edb810bfc9c0bef6a8',
 u'message': u'Add support for keywords',
 u'timestamp': u'2010-11-17T16:14:37-08:00',
 u'url': u'https://github.com/LegNeato/bztools/commit/80539c359d22ca35f61c34edb810bfc9c0bef6a8'},
 {u'author': {u'email': u'clegnitto@mozilla.com',
 u'name': u'Christian Legnitto',
 u'username': u'LegNeato'},
 u'files': {u'added': [],
 u'modified': [u'README.rst'],
 u'removed': []},
 u'id': u'4d69ae955e6f877000ecfe17def333b32973070b',
 u'message': u'Change readme to point to my repo (and a test of AMQP GitHub service hook)',
 u'timestamp': u'2010-11-22T15:16:26-08:00',
 u'url': u'https://github.com/LegNeato/bztools/commit/4d69ae955e6f877000ecfe17def333b32973070b'},
 {u'author': {u'email': u'clegnitto@mozilla.com',
 u'name': u'Christian Legnitto',
 u'username': u'LegNeato'},
 u'files': {u'added': [],
 u'modified': [u'bugzilla/models.py'],
 u'removed': []},
 u'id': u'0ccf64aa593e96a19529b9c9a3b1e0098c626108',
 u'message': u'Add some string representations',
 u'timestamp': u'2010-11-22T18:19:32-08:00',
 u'url': u'https://github.com/LegNeato/bztools/commit/0ccf64aa593e96a19529b9c9a3b1e0098c626108'}],
 u'compare': u'https://github.com/LegNeato/bztools/compare/9aa2099...0ccf64a',
 u'forced': False,
 u'ref': u'refs/heads/master',
 u'ref_name': u'master',
 u'repository': {u'created_at': u'2010/11/15 14:45:56 -0800',
 u'description': u'Models and scripts to access the Bugzilla REST API.',
 u'fork': True,
 u'forks': 0,
 u'has_downloads': True,
 u'has_issues': False,
 u'has_wiki': True,
 u'homepage': u'',
 u'name': u'bztools',
 u'open_issues': 0,
 u'owner': {u'email': u'clegnitto@mozilla.com',
 u'name': u'LegNeato'},
 u'private': False,
 u'pushed_at': u'2010/11/22 19:17:25 -0800',
 u'url': u'https://github.com/LegNeato/bztools',
 u'watchers': 2}}}

Now that this service exists Pulse can get messages about Mozilla checkins for projects hosted on GitHub, making Pulse the one-stop shop for real-time Mozilla data...once the Bugzilla extension, MediaWiki extension, and Mercurial extension are put into production of course.

20Aug/10Off

Push notifications for Bugzilla!

I've had some downtime between Firefox releases and chose to work on a pet project on-and-off for the past week. I'm announcing it today as bugzilla-amqp.

What is bugzilla-amqp?

A server-side Bugzilla extension that sends messages to a message broker via AMQP whenever a Bugzilla object (bug, keyword, component, etc) is created or modified.

Why?

It enables push notifications for interesting events in Bugzilla! This is a big deal. Tools no longer have to poll the various APIs when dealing with bug data...instead they can sit back and get notified! Want to know when you are CC'd? Easy! Want to know when a new bug is written? No problem! Take a look at the quick demo video (webm, theora...warning, large!)

Because it talks AMQP, tools interested in the Bugzilla messages/events can be written in just about any language you want for any platform you want.

The impetus for writing this extension came from the desire to integrate Mozilla Pulse (running RabbitMQ) with bugzilla.mozilla.org, having push messages end-to-end.

Sounds awesome! I want this on bugzilla.mozilla.org now!

It won't be rolled out on bmo for a bit yet. All these need to happen:

  1. There are some features that need to be added first (like, uh, security)
  2. After that, because there is a fair amount of code (as far as Bugzilla extensions go), it will likely need to go through a security review
  3. Performance testing needs to happen so that it doesn't bring down bmo inadvertently
  4. The server running Mozilla Pulse needs to get beefier and the traffic expectations with IT have to be revisited (I promised them it was a prototype after all...)

I have filed bug 589322 to track putting the extension into production on bmo.

Ok, still sounds awesome...where do I get the code?

I've put it at http://github.com/LegNeato/bugzilla-amqp. Let me know if you use it and/or find any issues and feel free to fork away!

Are you some hardcore Bugzilla hacker?

Nope, I'm a Firefox release manager :-) . The Bugzilla extension system is pretty easy...I highly suggest you take a look if you ever wished Bugzilla did something differently or wanted a feature added.