You asked for it

Friday 13 February 2009This is close to 16 years old. Be careful.

I’ve always been a big fan of adding code to a product just to measure, debug, and diagnose the product itself. On a web project, it’s easy to add extra URLs that are only for internal use, and provide insight into the workings of the code or the health of your data.

Yesterday evening, one of them did its small job perfectly. Just as I was getting into my car, an engineer called to report that a spate of stack traces had been reported from the production servers. We use Django, and take advantage of the emailed stack trace reports. These errors were of an unusual nature, one that would spell big trouble if they persisted. After the initial burst, there weren’t more reports, but there weren’t any other stack traces either. It could be that the problem had metastasized so quickly that the stack trace reporting wasn’t working either. It had happened before.

How to tell the difference between a momentary blip that had passed, and a problem that broke the error reporting? Simple: we have an endpoint with this implementation:

def raise_error(request):
    raise Exception("You asked for it!")

Visiting that URL generates a stack trace, and you can see if the error reporting mechanisms are working properly. One quick browser visit, a stack trace appeared in our inbox, and we knew: they were.

Comments

[gravatar]
That's brilliant! I'm totally implementing that in our code.
[gravatar]
I love your blog because your posts are never (and let me repeat: never) banal.

Thanks!
[gravatar]
really cool way to leave code behind that will help you out later

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.