GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - modern-python/lite-bootstrap: Lightweight bootstrap for production-ready Python microservices

BranchesTags
Open more actions menu

Latest commit

 

History

545 Commits
545 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
benchmarks
benchmarks
 
 
docs
docs
 
 
lite_bootstrap
lite_bootstrap
 
 
overrides
overrides
 
 
scripts
scripts
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
CLAUDE.md
CLAUDE.md
 
 
CONTEXT.md
CONTEXT.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
context7.json
context7.json
 
 
justfile
justfile
 
 
mkdocs.yml
mkdocs.yml
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

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, FastStream, and FastMCP services in a few lines.

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, including an offline version
  • health-checks

Those instruments can be bootstrapped for:

  • Litestar
  • FastStream
  • FastAPI
  • FastMCP
  • services and scripts without frameworks

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) is not supported. The second bootstrapper warns at construction, and its bootstrap() raises ConfigurationError.
  • One OpenTelemetryInstrument per process. bootstrap() calls opentelemetry.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.
  • Failed bootstrap is terminal. If an instrument or application preparation raises, successfully started instruments are torn down in reverse order. Cleanup failures are attached as notes to the original exception. The bootstrapper cannot be reused, and a later teardown() does nothing. Rollback does not undo arbitrary changes made by the instrument that raised.
  • 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:

  • 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 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 with no pydantic / pydantic-settings runtime dependency, which is what makes it "lite". microbootstrap configures everything through pydantic-settings models.
  • Extras. lite-bootstrap has one mandatory runtime dependency, the pure-Python typing-extensions. Every instrument (sentry, otl, logging, pyroscope) and every framework (fastapi, litestar, faststream, fastmcp) is its own extra, plus an opt-in orjson speedup for logging, per-pair combos (fastapi-sentry, litestar-otl, faststream-metrics, …) and *-all rollups. 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.
  • Free-threading. lite-bootstrap runs on free-threaded CPython 3.14t and 3.15t. Every extra whose dependencies are pure Python installs there. The rest are blocked upstream: orjson and pyroscope have no free-threaded wheels, and otl needs grpcio, so use otl-http instead.
  • Scope. lite-bootstrap only wires instruments. It does not include a Granian server runner or a console writer.

Links

  • Documentation
  • Upgrading to 2.x
  • PyPI
  • License

If this project saves you time, consider giving it a star on GitHub.

Part of modern-python

Browse the full list of templates and libraries in modern-python; the org profile has the categorized index.

About

Lightweight bootstrap for production-ready Python microservices

lite-bootstrap.modern-python.org

Topics

bootstrapfastapifastmcpfaststreamhealthchecklitestarmicroservicesopentelemetryprometheuspythonsentrystructlog

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

13 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.