Is there an open-source way to measure Python code coverage from production traffic?

0
0
Asked By MellowCedar42 On

Our backend services are mostly built with FastAPI, and I'm looking for open-source runtime coverage instrumentation for Python. Ideally, it would show which lines of code were executed by real production traffic over something like the last 30 days. I've seen solutions for this in Go and Java, but I'm not sure what the best Python options are. I'm specifically interested in runtime line coverage, rather than only request tracing or performance profiling.

2 Answers

Answered By QuietMarble5 On

If you want production observability rather than strict coverage data, Pydantic Logfire is worth considering. It integrates nicely with Python and FastAPI applications and can help reveal what your services are actually doing in production.

AmberKite28 -

I’ve had a good experience with Logfire as well. It was straightforward to integrate and gave us useful visibility into the application’s runtime behavior.

Answered By BriskWalnut63 On

coverage.py is the standard tool to investigate, but it’s primarily designed for test-time coverage. Running it continuously across production traffic for 30 days could add overhead and produce a lot of data, so you’d need to evaluate the performance and storage impact carefully.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.