Releases
0.21.1
Compare
Sorry, something went wrong.
No results found
tarsil
released this
09 Oct 15:48
Added
OpenTelemetry integration under lilya.contrib.opentelemetry:
Introduced OpenTelemetryMiddleware for automatic request tracing.
Creates one SERVER span per HTTP request.
Records standard HTTP attributes (method, path, status, client.address, url.query, etc.).
Captures exceptions and marks spans with StatusCode.ERROR.
Handles parent context extraction from inbound headers for trace propagation.
Added setup_tracing(config: OpenTelemetryConfig | None) helper.
Initializes a global TracerProvider with a BatchSpanProcessor.
Automatically selects between ConsoleSpanExporter, OTLP/gRPC, and OTLP/HTTP exporters.
Safe to call multiple times (idempotent).
Added OpenTelemetryConfig dataclass for configuration.
Supports fields:
service_name: logical name reported to telemetry backends.
exporter: "otlp" or "console".
otlp_endpoint: e.g. "http://localhost:4317" or "http://collector:4318".
otlp_insecure: disable TLS verification for gRPC exporters.
sampler: "parentbased_always_on", "always_on", or "always_off".
Added get_tracer_provider() utility to retrieve the active TracerProvider.
Async testing utilities :
Introduced AsyncTestClient and create_async_client() to allow fully asynchronous testing of Lilya apps.
Both support full middleware stacks, including OpenTelemetryMiddleware.
Enables concurrent request tests and real async span creation with in-memory exporters.
Contrib Shortcuts:
New abort function to raise HTTP exceptions.
New responses shorcuts including:
send_json(): send JSON responses with proper headers.
json_error(): send JSON error responses with status codes.
stream(): stream response content from async generators.
empty(): return empty 204 No Content responses.
redirect(): send HTTP redirects with proper status codes and headers.
forbidden(): send 403 Forbidden responses.
not_found(): send 404 Not Found responses.
unauthorized(): send 401 Unauthorized responses.
Changed
redirect now is in lilya.contrib.responses.shortcuts.
Fixed
send_file now correctly sets Content-Disposition headers for file downloads.
Late binding in the make_response.
You can’t perform that action at this time.