Cox Media GroupKryptonite
Monkeying Around with Python at New Relic
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.