Metadata-Version: 2.4
Name: lite-bootstrap
Version: 1.1.0
Summary: Lite package for bootstrapping new microservices
Keywords: python,microservice,bootstrap,opentelemetry,sentry,error-tracing,fastapi,litestar,faststream,structlog,fastmcp
Author: Artur Shiriev
Author-email: Artur Shiriev <me@shiriev.ru>
License-Expression: MIT
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: orjson
Requires-Dist: fastapi ; extra == 'fastapi'
Requires-Dist: lite-bootstrap[fastapi-sentry,fastapi-otl,fastapi-logging,fastapi-metrics,pyroscope] ; extra == 'fastapi-all'
Requires-Dist: lite-bootstrap[fastapi,logging] ; extra == 'fastapi-logging'
Requires-Dist: lite-bootstrap[fastapi] ; extra == 'fastapi-metrics'
Requires-Dist: prometheus-fastapi-instrumentator>=6.1 ; extra == 'fastapi-metrics'
Requires-Dist: lite-bootstrap[fastapi,otl] ; extra == 'fastapi-otl'
Requires-Dist: opentelemetry-instrumentation-fastapi ; extra == 'fastapi-otl'
Requires-Dist: lite-bootstrap[fastapi,sentry] ; extra == 'fastapi-sentry'
Requires-Dist: fastmcp ; extra == 'fastmcp'
Requires-Dist: lite-bootstrap[fastmcp,fastmcp-metrics,sentry,logging,pyroscope] ; extra == 'fastmcp-all'
Requires-Dist: lite-bootstrap[fastmcp] ; extra == 'fastmcp-metrics'
Requires-Dist: prometheus-client>=0.20 ; extra == 'fastmcp-metrics'
Requires-Dist: faststream ; extra == 'faststream'
Requires-Dist: lite-bootstrap[faststream-sentry,faststream-otl,faststream-logging,faststream-metrics,pyroscope] ; extra == 'faststream-all'
Requires-Dist: lite-bootstrap[sentry,otl,logging,faststream,faststream-metrics,pyroscope] ; extra == 'faststream-all'
Requires-Dist: lite-bootstrap[faststream,logging] ; extra == 'faststream-logging'
Requires-Dist: lite-bootstrap[faststream] ; extra == 'faststream-metrics'
Requires-Dist: prometheus-client>=0.20 ; extra == 'faststream-metrics'
Requires-Dist: lite-bootstrap[faststream,otl] ; extra == 'faststream-otl'
Requires-Dist: lite-bootstrap[faststream,sentry] ; extra == 'faststream-sentry'
Requires-Dist: lite-bootstrap[sentry,otl,logging,pyroscope] ; extra == 'free-all'
Requires-Dist: litestar>=2.9 ; extra == 'litestar'
Requires-Dist: lite-bootstrap[litestar-sentry,litestar-otl,litestar-logging,litestar-metrics,pyroscope] ; extra == 'litestar-all'
Requires-Dist: lite-bootstrap[litestar,logging] ; extra == 'litestar-logging'
Requires-Dist: lite-bootstrap[litestar] ; extra == 'litestar-metrics'
Requires-Dist: prometheus-client>=0.20 ; extra == 'litestar-metrics'
Requires-Dist: lite-bootstrap[litestar,otl] ; extra == 'litestar-otl'
Requires-Dist: opentelemetry-instrumentation-asgi>=0.46b0 ; extra == 'litestar-otl'
Requires-Dist: lite-bootstrap[litestar,sentry] ; extra == 'litestar-sentry'
Requires-Dist: structlog ; extra == 'logging'
Requires-Dist: opentelemetry-api ; extra == 'otl'
Requires-Dist: opentelemetry-sdk ; extra == 'otl'
Requires-Dist: opentelemetry-exporter-otlp ; extra == 'otl'
Requires-Dist: opentelemetry-instrumentation ; extra == 'otl'
Requires-Dist: pyroscope-io ; extra == 'pyroscope'
Requires-Dist: sentry-sdk ; extra == 'sentry'
Requires-Python: >=3.10, <4
Project-URL: repository, https://github.com/modern-python/lite-bootstrap
Provides-Extra: fastapi
Provides-Extra: fastapi-all
Provides-Extra: fastapi-logging
Provides-Extra: fastapi-metrics
Provides-Extra: fastapi-otl
Provides-Extra: fastapi-sentry
Provides-Extra: fastmcp
Provides-Extra: fastmcp-all
Provides-Extra: fastmcp-metrics
Provides-Extra: faststream
Provides-Extra: faststream-all
Provides-Extra: faststream-logging
Provides-Extra: faststream-metrics
Provides-Extra: faststream-otl
Provides-Extra: faststream-sentry
Provides-Extra: free-all
Provides-Extra: litestar
Provides-Extra: litestar-all
Provides-Extra: litestar-logging
Provides-Extra: litestar-metrics
Provides-Extra: litestar-otl
Provides-Extra: litestar-sentry
Provides-Extra: logging
Provides-Extra: otl
Provides-Extra: pyroscope
Provides-Extra: sentry
Description-Content-Type: text/markdown

Lite-Bootstrap
==
[![Test Coverage](https://codecov.io/gh/modern-python/lite-bootstrap/branch/main/graph/badge.svg)](https://codecov.io/gh/modern-python/lite-bootstrap)
[![Supported versions](https://img.shields.io/pypi/pyversions/lite-bootstrap.svg)](https://pypi.python.org/pypi/lite-bootstrap)
[![downloads](https://img.shields.io/pypi/dm/lite-bootstrap.svg)](https://pypistats.org/packages/lite-bootstrap)
[![GitHub stars](https://img.shields.io/github/stars/modern-python/lite-bootstrap)](https://github.com/modern-python/lite-bootstrap/stargazers)

`lite-bootstrap` assists you in creating applications with all the necessary instruments already set up.

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:

- [LiteStar](https://lite-bootstrap.readthedocs.io/integrations/litestar)
- [FastStream](https://lite-bootstrap.readthedocs.io/integrations/faststream)
- [FastAPI](https://lite-bootstrap.readthedocs.io/integrations/fastapi)
- [FastMCP](https://lite-bootstrap.readthedocs.io/integrations/fastmcp)
- [services and scripts without frameworks](https://lite-bootstrap.readthedocs.io/integrations/free)

## Lifecycle constraints

A few constraints that aren't obvious from the API:

- **One bootstrapper per application instance.** Constructing two `FastAPIBootstrapper`s around the same `fastapi.FastAPI` (or two `FastMcpBootstrapper`s 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:

- with LiteStar - [litestar-sqlalchemy-template](https://github.com/modern-python/litestar-sqlalchemy-template)
- with FastAPI - [fastapi-sqlalchemy-template](https://github.com/modern-python/fastapi-sqlalchemy-template)

## Part of `modern-python`

Browse the full list of templates and libraries in
[`modern-python`](https://github.com/modern-python) — see the org profile for the
categorized index.

## 📚 [Documentation](https://lite-bootstrap.readthedocs.io)

## 📦 [PyPi](https://pypi.org/project/lite-bootstrap)

## 📝 [License](LICENSE)

## Acknowledgements

`lite-bootstrap` is inspired by [`microbootstrap`](https://github.com/community-of-python/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` ships only `orjson` as a runtime dependency; every instrument (`sentry`, `otl`, `logging`, `pyroscope`) and every framework (`fastapi`, `litestar`, `faststream`) is its own extra, with per-pair combos (`fastapi-sentry`, `litestar-otl`, `faststream-metrics`, …) and `*-all` rollups. You install only what you actually use. `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.
