The Hitchhiker's Guide to Advanced Python Monitoring
summary
Covers concrete tradeoffs and working techniques across Python versions: settrace/setprofile are comprehensive but too slow for production, import hooks add decorators via AST transforms at load time (shows compile()/ast manipulations and an example that injects decorators into functions), eval hooks intercept frame evaluation for powerful runtime instrumentation but carry safety/performance risks, and PEP 669 in Python 3.12 enables filtered, performant monitoring by registering event-specific callbacks so monitors only touch interesting code paths.
AI-written summary · about
chapters (10)
- 0:00Introduction to Python monitoring
- 1:13Python 1.4 monitoring mechanisms
- 3:23sys.settrace limitations
- 5:54Python 2.3 import hooks
- 8:31Implementing import hooks
- 11:26Usage and risks of import hooks
- 12:53Python 3.6 eval hooks
- 17:21Python 3.12 low-overhead profiling
- 19:21Modern monitoring APIs
- 21:14Choosing the right tool
related talks
30mPython 3.12's new monitoring and debugging API
28mWhat makes a Python debugger possible and how can we make it 100x faster
24mEngage the Hyper-Python
29mModern observability for Python
12mDebugging Python in Production: Practical Techniques Beyond Print Statements
31mTracing, Profiling & Debugging in Production (eBPF)
56mPython Profiling State of the World
37mTuning Python applications can dramatically increase performance
