Skip to main content

Lightweight bootstrap for production-ready Python microservices

Project description

lite-bootstrap

PyPI version Supported Python versions Downloads Coverage CI License GitHub stars Context7 uv Ruff ty

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:

  • sentry
  • prometheus
  • opentelemetry
  • pyroscope - with OpenTelemetry trace-profile linking
  • structlog
  • cors
  • swagger - with additional offline version support
  • health-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 same fastapi.FastAPI (or two FastMcpBootstrappers around the same FastMCP) stacks teardown hooks and re-wraps the lifespan. The library warns and skips the second attachment, but the second bootstrapper's teardown() won't fire on ASGI shutdown.
  • One OpenTelemetryInstrument per process. bootstrap() calls opentelemetry.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 TeardownError at the end with all collected failures.

Usage examples:

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 Bootstrapper per 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-bootstrap uses frozen dataclass configs (no pydantic / pydantic-settings runtime dependency), which is what makes it "lite". microbootstrap configures everything through pydantic-settings models.
  • Granular extras: lite-bootstrap has no mandatory runtime dependencies; every instrument (sentry, otl, logging, pyroscope) and every framework (fastapi, litestar, faststream) is its own extra, plus an opt-in orjson speedup for logging, per-pair combos (fastapi-sentry, litestar-otl, faststream-metrics, …) and *-all rollups. You install only what you actually use. It also runs on free-threaded CPython (3.13t/3.14t) — see architecture/free-threading.md. microbootstrap bundles 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-bootstrap is 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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lite_bootstrap-1.3.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lite_bootstrap-1.3.1-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file lite_bootstrap-1.3.1.tar.gz.

File metadata

  • Download URL: lite_bootstrap-1.3.1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}

File hashes

Hashes for lite_bootstrap-1.3.1.tar.gz
Algorithm Hash digest
SHA256 981b35ea184fbe16206cef20cae23a61f707146bff3485da0e8d803a773972c8
MD5 61f232ab4092ba32b9d6a9cc25f8436a
BLAKE2b-256 c045018d7b35a1817cc2c4770b0a0051a51d1dfcb9d34b60927399381636f83d

See more details on using hashes here.

File details

Details for the file lite_bootstrap-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: lite_bootstrap-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}

File hashes

Hashes for lite_bootstrap-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8fa83d4e14ab8a21b20a88e59c7996024dcbc303e6db4f7fc0e6f668bde5a0f7
MD5 c21c5f8e4d427ec82d04e21bead8d431
BLAKE2b-256 c9cf9d9183fbd48d1aae5b25b2c517d864d0853851d218d49c55ba8ebd79b2e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page