Rate Limiting & Observability¶
Rate Limiting¶
fast-agent-stack provides Redis-backed fixed-window rate limiting via fastapi-redis-sdk.
Enable Rate Limiting¶
class Settings(BaseSettings):
include_rate_limit: bool = True
rate_limit_requests: int = 100 # max requests per window
rate_limit_period: int = 60 # window size in seconds
redis_url: str = "redis://localhost:6379"
Rate limiting is applied globally to all routes when enabled. The limit is per client IP, enforced via a Redis Lua script (atomic INCR + EXPIRE).
Response Headers¶
Clients receive standard rate-limit headers on every response:
When the limit is exceeded, the server returns 429 Too Many Requests.
Observability (OpenTelemetry)¶
fast-agent-stack auto-instruments with OpenTelemetry. Every request generates a trace span with HTTP metadata.
Enable Tracing¶
class Settings(BaseSettings):
tracing_enabled: bool = True
otel_exporter_endpoint: str = "http://localhost:4317" # OTLP gRPC
Jaeger (default backend)¶
Open http://localhost:16686 to view traces.
Custom Exporter¶
Set otel_exporter_endpoint to any OTLP-compatible backend (Grafana Tempo, Honeycomb, Datadog OTLP endpoint, etc.).
What Gets Traced¶
- Every HTTP request (method, path, status code, duration)
- Database queries (SQLAlchemy instrumentation)
- External service calls via the
tracercontext manager