Auto-instrumentation SDK for FastAPI and Flask: zero-code latency, error rates, and status codes shipped to a Reqly collector.
Project description
Reqly
Auto-instrumentation SDK for FastAPI and Flask. One line captures latency, status codes, and error rates for every request and ships them to an Reqly collector.
Install
pip install reqly
(For local development against this monorepo: pip install -e ./sdk[dev].)
Usage
from fastapi import FastAPI
import reqly
app = FastAPI()
reqly.instrument(app, service_name="checkout-api")
from flask import Flask
import reqly
app = Flask(__name__)
reqly.instrument(app, service_name="checkout-api")
instrument() auto-detects FastAPI vs Flask — no other code changes needed.
Configuration
Every option can be passed as a kwarg to instrument() or set via environment variable. Resolution order: kwarg > env var > default.
| kwarg | env var | default |
|---|---|---|
service_name |
REQLY_SERVICE_NAME |
sys.argv[0] basename |
collector_url |
REQLY_COLLECTOR_URL |
http://localhost:8000 |
api_key |
REQLY_API_KEY |
None |
sample_rate |
REQLY_SAMPLE_RATE |
1.0 |
flush_interval_seconds |
REQLY_FLUSH_INTERVAL_SECONDS |
5.0 |
max_batch_size |
REQLY_MAX_BATCH_SIZE |
200 |
max_queue_size |
REQLY_MAX_QUEUE_SIZE |
2000 |
ignore_routes |
REQLY_IGNORE_ROUTES (comma-separated) |
/health,/metrics |
capture_request_body |
REQLY_CAPTURE_REQUEST_BODY |
False |
Design guarantees
- Fails open. Any internal SDK error is caught and logged once; instrumentation then disables itself rather than risk repeatedly raising into your app. A slow or unreachable collector never slows down your app — all shipping happens off a background thread with strict per-phase HTTP timeouts.
- Bounded cardinality. Captured routes are the framework's matched route template (
/users/{id}), never the raw path (/users/123). Unmatched paths (404s, scanners) collapse into a single__unmatched__bucket instead of blowing up cardinality. - Bounded memory. Events are held in a fixed-size in-memory queue; under sustained backpressure, the oldest events are dropped (and counted) rather than growing unbounded or blocking request threads.
Architecture
See ../ARCHITECTURE.md for the full design rationale (why pure ASGI middleware over BaseHTTPMiddleware, why a background thread over asyncio.create_task, why httpx over requests, etc).
Running tests
pip install -e .[dev]
pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reqly-0.1.0.tar.gz.
File metadata
- Download URL: reqly-0.1.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b6b16e757739ac4a5f0381ece2760689e66416bfc9e5a88546960259d4b7265
|
|
| MD5 |
7746ede2f7758e9fe48dfb1cb5169865
|
|
| BLAKE2b-256 |
94b78525fdbdc2e970709b1a9cce49d08855d0f75909dd488864b414ca2218ad
|
File details
Details for the file reqly-0.1.0-py3-none-any.whl.
File metadata
- Download URL: reqly-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b60f9ff59061bf8e1b7d18a8a78f450933790e74525bebfa21da5d036ea856d9
|
|
| MD5 |
c9968de084912186a10a44031a345955
|
|
| BLAKE2b-256 |
43ed384c337e370c99bd39232276f05b41903f3cac1f31893ee54711c5f10ad6
|