Wrapture is one library that does both mock-style testing and zero-code production tracing
Simon Willison's Blog·medium signal
Graham Dumpleton released wrapture, which Simon Willison calls 'a new monkey patching library that serves both testing and observability (think New Relic style tracing) at the same time.' It patches methods, attributes, dicts and generators, records call sequences as timelines, traces live applications via TOML config with no source changes, and exports to OpenTelemetry, with instrumentation for Flask, Django, FastAPI and SQLAlchemy. Still alpha, though Willison calls it production-ready and 'one of those Swiss Army Knife packages.'