Conference Schedule

Track one or two? Eeenie, meenie, miney, moe…

log in to bookmark.

Monkeying Around with Python at New Relic

A Talk presented by Graham Dumpleton


Tuesday, September 6th 11:20 a.m.–noon




This session will cover the challenges of creating a production application performance monitoring system for Python. It includes an overview of the architecture of the system, as well as how it hooks into Django and captures details about web transactions, database transactions, memcache requests, exceptions and much more.


This session provides a technical review of the challenges associated with instrumenting Python for production monitoring. How do you place monitoring hooks into code that cannot be modified directly in order to collect meaningful performance data? Concepts covered in this session will include:

  • Using context manager objects to time execution of code.
  • Using context manager objects to catch details of exceptions.
  • Applying a context manager to functions using wrappers and decorators.
  • Applying a context manager to WSGI applications and components.
  • How to go about applying the above to existing code using monkey patching.
  • Deriving the name of a wrapped object for identification purposes.
  • Using post import hooks as a means to trigger monkey patching.
  • Driving the process of monkey patching from a configuration file.

The talk includes real-world examples of how these mechanisms have been used to add instrumentation to the Django web framework in order to collect actionable performance data.