Skip to content

Usage with FastStream

1. Install lite-bootstrap[faststream-all]:

uv add lite-bootstrap[faststream-all]
pip install lite-bootstrap[faststream-all]
poetry add lite-bootstrap[faststream-all]

Read more about available extras here:

2. Define bootstrapper config and build you application:

from lite_bootstrap import FastStreamConfig, FastStreamBootstrapper
from faststream.asgi import AsgiFastStream
from faststream.redis.opentelemetry import RedisTelemetryMiddleware
from faststream.redis.prometheus import RedisPrometheusMiddleware
from faststream.redis import RedisBroker


broker = RedisBroker()
bootstrapper_config = FastStreamConfig(
    service_name="microservice",
    service_version="2.0.0",
    service_environment="test",
    opentelemetry_endpoint="otl",
    opentelemetry_middleware_cls=RedisTelemetryMiddleware,
    prometheus_metrics_path="/custom-metrics/",
    prometheus_middleware_cls=RedisPrometheusMiddleware,
    sentry_dsn="https://testdsn@localhost/1",
    health_checks_path="/custom-health/",
    logging_buffer_capacity=0,
    application=AsgiFastStream(broker),
)
bootstrapper = FastStreamBootstrapper(bootstrapper_config)
application = bootstrapper.bootstrap()

Read more about available configuration options here: