🐮 fastapi-calf
A lightweight, real-time observability for FastAPI.
fastapi-calf watches decorated API routes and presents request activity,
latency, throughput, failures, CPU, memory, and worker information in a compact
terminal UI. Monitoring is intentionally best-effort: if the dashboard is not
available, your API continues serving requests normally.
Highlights
- ⚡ Live requests-per-second and latency sparklines
- 🧭 Per-route request, failure, status, and response-time statistics
- 🖥️ CPU and memory usage across multiple application workers
- 🎮
CUDA_VISIBLE_DEVICESreporting for GPU-aware deployments - 🛡️ Short-timeout event delivery that never takes down the application
Quick start
Install the runtime dependencies from the repository root:
python -m pip install fastapi uvicorn rich psutil
Start the monitoring dashboard on port 8005:
python -m fastapi_calf.daemon --port 8005
In another terminal, start the included example API with four workers:
python -m uvicorn server.app:app --port 8000 --workers 4
Visit http://127.0.0.1:8000/docs to explore the API while the terminal
dashboard updates in real time.
Instrumenting an API
Configure the monitor once, then decorate the routes you want to observe:
from fastapi import FastAPI, Request
from fastapi_calf import Calf, lookout
app = FastAPI()
Calf.listen(port=8005)
@app.get("/health")
@lookout
def health(request: Request):
return {"status": "healthy"}
@app.post("/jobs")
@lookout
async def create_job(request: Request):
payload = await request.json()
return {"accepted": True, "job": payload}
The Request parameter allows @lookout to capture the method, path, query
parameters, request size, status, and timing without changing the response.
Tests and traffic simulation
Install the testing tools and run the correctness suite:
python -m pip install -r requirements-test.txt
python -m pytest tests/test_api.py -q
The load runner starts four Uvicorn workers, verifies every sample endpoint, and pushes 100 concurrent API calls in a short burst:
python -m tests.load_test
Customize a run with --requests, --concurrency, and --workers. See
TESTING.md for additional examples.
Project layout
fastapi_calf/ monitoring library and terminal dashboard
server/ instrumented example FastAPI application
tests/ endpoint and concurrent load tests
Status: This is an early-stage project intended for experimentations with ML pipelines and POCs.
Release files for fastapi-calf 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_calf-0.1.1.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_calf-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / fastapi_calf-0.1.1.tar.gz
| Download URL | fastapi_calf-0.1.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c44e1eb7c1edb91703aeb2e06e1f678dfad8aa43f87dd58628f1ba82eb3cf315
|
|
BLAKE2b-256 checksum How to use checksums |
2dd50cb1998ce2bda32ee9a411770718dfccc3df560f431e052a683a5fa446d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / fastapi_calf-0.1.1-py3-none-any.whl
| Download URL | fastapi_calf-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ee4606b6ab76dc30336d4b1ea719bdc916f29a31763fb55d0d00e9d5e1b8124
|
|
BLAKE2b-256 checksum How to use checksums |
22678840779ba5594a8edf62aab041d0381d4b9149e3c24f77941559570834e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|