lite-bootstrap wires production observability (OpenTelemetry, Prometheus, Sentry, and structlog) into FastAPI, Litestar, FastStream, and FastMCP services in a few lines.
With lite-bootstrap, you receive an application with lightweight built-in support for:
sentryprometheusopentelemetrypyroscope, with OpenTelemetry trace-profile linkingstructlogcorsswagger, including an offline versionhealth-checks
Those instruments can be bootstrapped for:
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) is not supported. The second bootstrapper warns at construction, and itsbootstrap()raisesConfigurationError. - One
OpenTelemetryInstrumentper process.bootstrap()callsopentelemetry.trace.set_tracer_provider(...), which the OTel SDK enforces as set-once: later 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
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 with nopydantic/pydantic-settingsruntime dependency, which is what makes it "lite".microbootstrapconfigures everything throughpydantic-settingsmodels. - Extras.
lite-bootstraphas one mandatory runtime dependency, the pure-Pythontyping-extensions. Every instrument (sentry,otl,logging,pyroscope) and every framework (fastapi,litestar,faststream,fastmcp) is its own extra, plus an opt-inorjsonspeedup for logging, per-pair combos (fastapi-sentry,litestar-otl,faststream-metrics, …) and*-allrollups.microbootstrapbundles the full observability stack (opentelemetry, sentry-sdk, structlog, pyroscope-io, rich, pydantic-settings, …) as base dependencies and only splits framework packages into extras. - Free-threading.
lite-bootstrapruns on free-threaded CPython 3.14t. Every extra whose dependencies are pure Python installs there. The rest are blocked upstream:orjsonandpyroscopehave no free-threaded wheels, andotlneedsgrpcio, so useotl-httpinstead. - Scope.
lite-bootstraponly wires instruments. It does not include a Granian server runner or a console writer.
Browse the full list of templates and libraries in
modern-python; the org profile has the categorized index.