Skip to content

Commit 01fcda3

Browse files
authored
docs: correct defaults, lifecycle and install facts (#267)
- README: second bootstrapper on one app raises ConfigurationError from bootstrap(); list FastMCP - configuration: Prometheus, swagger and health checks are on by default; OTel also enabled by opentelemetry_log_traces; document opentelemetry_insecure default and warning, and the ignored litestar_logging_middleware_config warning; drop removed-field history - quickstart: say which instruments are on by default; skipped_instruments omits dep-missing skips - free: use FreeConfig instead of the backward-compatible alias - performance: include the logging table the text refers to; trim prose - fastmcp: drop version-history paragraph - quote extras in install commands so zsh does not glob them; Litestar spelling
1 parent 9f7d5f7 commit 01fcda3

12 files changed

Lines changed: 57 additions & 57 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
1919
[![ty](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ty/main/assets/badge/v0.json)](https://github.com/astral-sh/ty)
2020

21-
`lite-bootstrap` wires production observability — OpenTelemetry, Prometheus, Sentry, and structlog — into FastAPI, Litestar, and FastStream services in a few lines, with no boilerplate.
21+
`lite-bootstrap` wires production observability — OpenTelemetry, Prometheus, Sentry, and structlog — into FastAPI, Litestar, FastStream, and FastMCP services in a few lines, with no boilerplate.
2222

2323
With `lite-bootstrap`, you receive an application with lightweight built-in support for:
2424

@@ -33,7 +33,7 @@ With `lite-bootstrap`, you receive an application with lightweight built-in supp
3333

3434
Those instruments can be bootstrapped for:
3535

36-
- [LiteStar](https://lite-bootstrap.modern-python.org/integrations/litestar/)
36+
- [Litestar](https://lite-bootstrap.modern-python.org/integrations/litestar/)
3737
- [FastStream](https://lite-bootstrap.modern-python.org/integrations/faststream/)
3838
- [FastAPI](https://lite-bootstrap.modern-python.org/integrations/fastapi/)
3939
- [FastMCP](https://lite-bootstrap.modern-python.org/integrations/fastmcp/)
@@ -43,7 +43,7 @@ Those instruments can be bootstrapped for:
4343

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

46-
- **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.
46+
- **One bootstrapper per application instance.** Constructing two `FastAPIBootstrapper`s around the same `fastapi.FastAPI` (or two `FastMcpBootstrapper`s around the same `FastMCP`) is not supported. The second bootstrapper warns at construction, and its `bootstrap()` raises `ConfigurationError`.
4747
- **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.
4848
- **`teardown()` is idempotent.** `BaseBootstrapper.teardown()` short-circuits if not bootstrapped; per-instrument teardown methods are safe to call multiple times.
4949
- **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.
@@ -52,7 +52,7 @@ A few constraints that aren't obvious from the API:
5252

5353
Usage examples:
5454

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

5858
## Acknowledgements
@@ -68,7 +68,7 @@ The following ideas were borrowed:
6868
The following intentionally differ:
6969

7070
- **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.
71-
- **Granular extras**: `lite-bootstrap` has exactly **one** mandatory runtime dependency, the pure-Python `typing-extensions`; 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): every extra whose dependencies are pure Python installs there, and the ones that don't are blocked upstream — `orjson` and `pyroscope` have no free-threaded wheels, and `otl` needs `grpcio`, so use `otl-http` instead. `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.
71+
- **Granular extras**: `lite-bootstrap` has exactly **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. 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 — `orjson` and `pyroscope` have no free-threaded wheels, and `otl` needs `grpcio`, so use `otl-http` instead. `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.
7272
- **Scope**: `lite-bootstrap` is deliberately narrow — only instrument wiring. It does not include a Granian server runner or a console writer.
7373

7474
## 📚 [Documentation](https://lite-bootstrap.modern-python.org)

‎benchmarks/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,15 @@ bare FastAPI, so the two tables are not directly comparable.
158158

159159
### 4c. Logging: cost per record, not per request
160160

161+
<!-- --8<-- [start:logging] -->
161162
Three records per request, in-process:
162163

163164
| scenario | +µs/req | delta |
164165
|---|---:|---:|
165166
| sentry-sdk defaults | +101.1 | |
166167
| `sentry_logs_level=None` (lite-bootstrap's default since #186) | +93.8 | −2.4 µs/record |
167168
| also `sentry_logging_breadcrumb_level=None` | +72.4 | −9.6 µs/record total |
169+
<!-- --8<-- [end:logging] -->
168170

169171
Two handlers run per log record. `SentryLogsHandler.emit` calls `self.format(record)` *before* it
170172
checks `has_logs_enabled(client.options)`, so with Sentry Logs disabled (the default, and

‎docs/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ With `lite-bootstrap`, you receive an application with lightweight built-in supp
2222

2323
Those instruments can be bootstrapped for:
2424

25-
- [LiteStar](integrations/litestar.md)
25+
- [Litestar](integrations/litestar.md)
2626
- [FastStream](integrations/faststream.md)
2727
- [FastAPI](integrations/fastapi.md)
2828
- [FastMCP](integrations/fastmcp.md)

‎docs/integrations/fastapi.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
=== "uv"
88

99
```bash
10-
uv add lite-bootstrap[fastapi-all]
10+
uv add "lite-bootstrap[fastapi-all]"
1111
```
1212

1313
=== "pip"
1414

1515
```bash
16-
pip install lite-bootstrap[fastapi-all]
16+
pip install "lite-bootstrap[fastapi-all]"
1717
```
1818

1919
=== "poetry"
2020

2121
```bash
22-
poetry add lite-bootstrap[fastapi-all]
22+
poetry add "lite-bootstrap[fastapi-all]"
2323
```
2424

2525
Read more about available extras [here](../introduction/installation.md).

‎docs/integrations/fastmcp.md‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
=== "uv"
66

77
```bash
8-
uv add lite-bootstrap[fastmcp-all]
8+
uv add "lite-bootstrap[fastmcp-all]"
99
```
1010

1111
=== "pip"
1212

1313
```bash
14-
pip install lite-bootstrap[fastmcp-all]
14+
pip install "lite-bootstrap[fastmcp-all]"
1515
```
1616

1717
=== "poetry"
1818

1919
```bash
20-
poetry add lite-bootstrap[fastmcp-all]
20+
poetry add "lite-bootstrap[fastmcp-all]"
2121
```
2222

2323
Read more about available extras [here](../introduction/installation.md).
@@ -62,10 +62,6 @@ FastMcpConfig(
6262
Enabled, each message is logged with its `method`, `source` and `type`, plus `duration` in
6363
nanoseconds. A message that raises is logged at exception level and the exception is re-raised.
6464

65-
This replaces `logging_turn_off_middleware`, which has been removed. Setting it now raises
66-
`TypeError`: the default flipped from on to off, so a service that configured the old field has to
67-
decide again rather than upgrade past the change unnoticed.
68-
6965
Set `health_checks_enabled=False` to omit the health route.
7066

7167
Teardown is wired through FastMCP's provider lifecycle — `bootstrapper.teardown()`

‎docs/integrations/faststream.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
=== "uv"
66

77
```bash
8-
uv add lite-bootstrap[faststream-all]
8+
uv add "lite-bootstrap[faststream-all]"
99
```
1010

1111
=== "pip"
1212

1313
```bash
14-
pip install lite-bootstrap[faststream-all]
14+
pip install "lite-bootstrap[faststream-all]"
1515
```
1616

1717
=== "poetry"
1818

1919
```bash
20-
poetry add lite-bootstrap[faststream-all]
20+
poetry add "lite-bootstrap[faststream-all]"
2121
```
2222

2323
Read more about available extras [here](../introduction/installation.md).

‎docs/integrations/free.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55
=== "uv"
66

77
```bash
8-
uv add lite-bootstrap[free-all]
8+
uv add "lite-bootstrap[free-all]"
99
```
1010

1111
=== "pip"
1212

1313
```bash
14-
pip install lite-bootstrap[free-all]
14+
pip install "lite-bootstrap[free-all]"
1515
```
1616

1717
=== "poetry"
1818

1919
```bash
20-
poetry add lite-bootstrap[free-all]
20+
poetry add "lite-bootstrap[free-all]"
2121
```
2222

2323
Read more about available extras [here](../introduction/installation.md).
2424

2525
## 2. Define bootstrapper config and build your application:
2626

2727
```python
28-
from lite_bootstrap import FreeBootstrapperConfig, FreeBootstrapper
28+
from lite_bootstrap import FreeConfig, FreeBootstrapper
2929

3030

31-
bootstrapper_config = FreeBootstrapperConfig(
31+
bootstrapper_config = FreeConfig(
3232
opentelemetry_endpoint="otl",
3333
sentry_dsn="https://testdsn@localhost/1",
3434
)

‎docs/integrations/litestar.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Usage with `Litestar`
22

3-
*Another example of usage with LiteStar - [litestar-sqlalchemy-template](https://github.com/modern-python/litestar-sqlalchemy-template)*
3+
*Another example of usage with Litestar - [litestar-sqlalchemy-template](https://github.com/modern-python/litestar-sqlalchemy-template)*
44

55
## 1. Install `lite-bootstrap[litestar-all]`:
66

77
=== "uv"
88

99
```bash
10-
uv add lite-bootstrap[litestar-all]
10+
uv add "lite-bootstrap[litestar-all]"
1111
```
1212

1313
=== "pip"
1414

1515
```bash
16-
pip install lite-bootstrap[litestar-all]
16+
pip install "lite-bootstrap[litestar-all]"
1717
```
1818

1919
=== "poetry"
2020

2121
```bash
22-
poetry add lite-bootstrap[litestar-all]
22+
poetry add "lite-bootstrap[litestar-all]"
2323
```
2424

2525
Read more about available extras [here](../introduction/installation.md).
@@ -122,8 +122,8 @@ LitestarConfig(
122122

123123
## Request body size limit
124124

125-
`LitestarBootstrapper` builds its app with `Litestar.from_config()`, which —
126-
unlike `Litestar(...)` — passes every `AppConfig` field explicitly and so
125+
`LitestarBootstrapper` builds its app with `Litestar.from_config()`, which,
126+
unlike `Litestar(...)`, passes every `AppConfig` field explicitly and so
127127
skips the 10 MB `request_max_body_size` default that `Litestar(...)` applies.
128128
Left as-is, that means every handler that reads a request body returns `500:
129129
'request_max_body_size' set to 'Empty' on all layers`

‎docs/introduction/configuration.md‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Additional parameters can also be supplied through the settings object:
2525

2626
Read more about sentry_sdk params [here](https://docs.sentry.io/platforms/python/configuration/options/).
2727

28-
Sentry is the second most expensive instrument in the stack, and the settings that actually move
29-
the number are not the ones most people reach for. See [Performance](performance.md).
28+
Sentry is the second most expensive instrument in the stack. Its cost comes almost entirely from the ASGI
29+
integration; see [Performance](performance.md).
3030

3131
### Sentry logging integration
3232

@@ -52,9 +52,8 @@ Under either, `sentry_logging_breadcrumb_level` is ignored and lite-bootstrap wa
5252

5353
Prometheus is the cheapest of the three non-logging instruments; see [Performance](performance.md).
5454

55-
To bootstrap Prometheus, you must provide at least:
56-
57-
- `prometheus_metrics_path`.
55+
Prometheus is on by default when its extra is installed, serving metrics at `prometheus_metrics_path`
56+
(default: `/metrics`). Set `prometheus_metrics_path` to an empty string to disable it.
5857

5958
Additional parameters:
6059

@@ -103,6 +102,7 @@ To bootstrap Opentelemetry, you must provide at least one of:
103102

104103
- `opentelemetry_endpoint`, for traces.
105104
- `opentelemetry_metrics_endpoint`, for metrics.
105+
- `opentelemetry_log_traces=True`, to log spans to stdout.
106106

107107
Additional parameters:
108108

@@ -111,7 +111,7 @@ Additional parameters:
111111
- `opentelemetry_endpoint` - will be passed to `OTLPSpanExporter` as endpoint. Under `opentelemetry_exporter_protocol="http"` this is a full URL (e.g. `http://collector:4318/v1/traces`).
112112
- `opentelemetry_namespace` - will be passed to the `Resource`.
113113
- `opentelemetry_exporter_protocol` - OTLP exporter transport: `"grpc"` (default, needs the `otl` extra) or `"http"` (needs the `otl-http` extra, no `grpcio` - installable on free-threaded Python).
114-
- `opentelemetry_insecure` - whether the gRPC OTLP connection is insecure (gRPC only; for `http` the endpoint URL scheme carries security).
114+
- `opentelemetry_insecure` - whether the gRPC OTLP connection is insecure (default: `True`; gRPC only; for `http` the endpoint URL scheme carries security). While it is `True`, an endpoint pointing at a non-local host triggers a warning that telemetry is sent unencrypted.
115115
- `opentelemetry_instrumentors` - a list of extra instrumentors.
116116
- `opentelemetry_log_traces` - traces will be logged to stdout.
117117
- `opentelemetry_sampler` - an `opentelemetry.sdk.trace.sampling.Sampler` deciding which traces are recorded. Unset, the SDK's own default applies: `parentbased_always_on`, which records every trace that is not the child of a non-recording remote parent, unless `OTEL_TRACES_SAMPLER` / `OTEL_TRACES_SAMPLER_ARG` say otherwise.
@@ -266,7 +266,7 @@ async def handler(request: Request) -> dict[str, str]:
266266
Additional parameters for Litestar's access-log middleware:
267267

268268
- `litestar_logging_middleware_enabled` - turn on request/response access logging (default: `False`).
269-
- `litestar_logging_middleware_config` - a caller-supplied `LoggingMiddlewareConfig` that replaces the built-in defaults wholesale.
269+
- `litestar_logging_middleware_config` - a caller-supplied `LoggingMiddlewareConfig` that replaces the built-in defaults wholesale. It is ignored, with a warning, unless `litestar_logging_middleware_enabled` is `True`.
270270

271271
See [the Litestar integration guide](../integrations/litestar.md#logging) for what gets logged and why access logging defaults to off.
272272

@@ -283,8 +283,7 @@ it defaults to off.
283283

284284
The per-MCP-message access log is **off by default**:
285285

286-
- `fastmcp_logging_middleware_enabled` - turn on the access log (default: `False`). Replaces
287-
`logging_turn_off_middleware`, which has been removed.
286+
- `fastmcp_logging_middleware_enabled` - turn on the access log (default: `False`).
288287

289288
See [the FastMCP integration guide](../integrations/fastmcp.md#logging) for what gets logged.
290289

@@ -329,11 +328,11 @@ To bootstrap swagger, you have the following parameters:
329328
- `swagger_path`
330329
- `swagger_offline_docs` - option to turn on offline docs.
331330

332-
For Litestar `swagger_path` is required to bootstrap swagger instrument.
331+
Swagger is on by default at `swagger_path` (default: `/docs`). For Litestar, set `swagger_path` to an empty string to disable it.
333332

334333
## Health checks
335334

336-
To bootstrap Health checks, you must provide set `health_checks_enabled` to True.
335+
Health checks are on by default; set `health_checks_enabled=False` to disable them.
337336

338337
Additional params:
339338

‎docs/introduction/installation.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ For example, if you want to bootstrap litestar with structlog and opentelemetry
2626
=== "uv"
2727

2828
```bash
29-
uv add lite-bootstrap[litestar-logging,litestar-otl]
29+
uv add "lite-bootstrap[litestar-logging,litestar-otl]"
3030
```
3131

3232
=== "pip"
3333

3434
```bash
35-
pip install lite-bootstrap[litestar-logging,litestar-otl]
35+
pip install "lite-bootstrap[litestar-logging,litestar-otl]"
3636
```
3737

3838
=== "poetry"
3939

4040
```bash
41-
poetry add lite-bootstrap[litestar-logging,litestar-otl]
41+
poetry add "lite-bootstrap[litestar-logging,litestar-otl]"
4242
```

0 commit comments

Comments
 (0)