lite-bootstrap wires production observability — OpenTelemetry, Prometheus, Sentry, and structlog — into FastAPI, Litestar, and FastStream services in a few lines, with no boilerplate.
With lite-bootstrap, you receive an application with lightweight built-in support for:
sentryprometheusopentelemetrypyroscope- with OpenTelemetry trace-profile linkingstructlogcorsswagger- with additional offline version supporthealth-checks
Those instruments can be bootstrapped for:
Lifecycle constraints
A few constraints that aren't obvious from the API:
- One bootstrapper per application instance. Constructing two
FastAPIBootstrappers around the samefastapi.FastAPI(or twoFastMcpBootstrappers around the sameFastMCP) stacks teardown hooks and re-wraps the lifespan. The library warns and skips the second attachment, but the second bootstrapper'steardown()won't fire on ASGI shutdown. - One
OpenTelemetryInstrumentper process.bootstrap()callsopentelemetry.trace.set_tracer_provider(...), which the OTel SDK enforces as set-once — subsequent calls log a warning and have no effect.teardown()flushes spans and closes exporters but can't reset the process-global pointer. teardown()is idempotent.BaseBootstrapper.teardown()short-circuits if not bootstrapped; per-instrument teardown methods are safe to call multiple times.- Partial teardown failures are aggregated. If an instrument's teardown raises, the bootstrapper continues with the rest of the instruments and raises
TeardownErrorat the end with all collected failures.
Usage examples:
- with LiteStar - litestar-sqlalchemy-template
- with FastAPI - fastapi-sqlalchemy-template
Acknowledgements
lite-bootstrap is inspired by microbootstrap — a single package that wires up the common observability stack (sentry, prometheus, opentelemetry, logging, cors, swagger, health-checks) for FastAPI / Litestar / FastStream services and for plain scripts.
The following ideas were borrowed:
- the overall surface — a
Bootstrapperper framework that composes a set of instruments, - the lifecycle model — each instrument has
bootstrap()/teardown()/is_ready()and is skipped when its optional dependency is not installed, - the catalog of supported instruments and supported frameworks.
The following intentionally differ:
- Configuration:
lite-bootstrapuses frozendataclassconfigs (nopydantic/pydantic-settingsruntime dependency), which is what makes it "lite".microbootstrapconfigures everything throughpydantic-settingsmodels. - Granular extras:
lite-bootstraphas exactly one mandatory runtime dependency, the pure-Pythontyping-extensions; every instrument (sentry,otl,logging,pyroscope) and every framework (fastapi,litestar,faststream) is its own extra, plus an opt-inorjsonspeedup for logging, per-pair combos (fastapi-sentry,litestar-otl,faststream-metrics, …) and*-allrollups. You install only what you actually use. It also runs on free-threaded CPython (3.13t/3.14t): every extra whose dependencies are pure Python installs there, and the ones that don't are blocked upstream —orjsonandpyroscopehave no free-threaded wheels, andotlneedsgrpcio, so useotl-httpinstead.microbootstrapbundles the full observability stack (opentelemetry, sentry-sdk, structlog, pyroscope-io, rich, pydantic-settings, …) as base dependencies and only splits framework packages into extras. - Scope:
lite-bootstrapis deliberately narrow — only instrument wiring. It does not include a Granian server runner or a console writer.
📚 Documentation
📦 PyPI
📝 License
Part of modern-python
Browse the full list of templates and libraries in
modern-python — see the org profile for the categorized index.
Release files for lite-bootstrap 1.8.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 | |
|---|---|---|---|
| lite_bootstrap-1.8.1.tar.gz | 1.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lite_bootstrap-1.8.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.7 MB
Release files / lite_bootstrap-1.8.1.tar.gz
| Download URL | lite_bootstrap-1.8.1.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c68e62fbc791a90a83a0f00f834d300fbb42c7c7e23f0b69397d64b55665178e
|
|
BLAKE2b-256 checksum How to use checksums |
2c4cd0857bac062d461b5b3a552b1e016fa30cd9f847b4a52dd3e00a403ccc9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / lite_bootstrap-1.8.1-py3-none-any.whl
| Download URL | lite_bootstrap-1.8.1-py3-none-any.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d592c65f68257871a38a199c219e1efd1a2920208dc61e847913cf7f2b4fca4
|
|
BLAKE2b-256 checksum How to use checksums |
82216d72648e00f2ff96ed0c5f05e9007d785edde929be4ced5de2d84bdaa5ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|