The Hostess SDK for Python. Native API Insights for FastAPI with one line of code.
pip install "hostess-python[fastapi]"from fastapi import FastAPI
from hostess_sdk.fastapi import instrument
app = FastAPI()
instrument(app)When deployed on Hostess, route-level traffic, latency, status codes, and error rates appear in Studio. No OTLP, collector, or Prometheus configuration required.
- Applies OpenTelemetry FastAPI instrumentation, so requests produce server
spans carrying the route template (
/items/{item_id}), method, and status code. Never raw paths or query strings. - Exports spans over OTLP/HTTP to the Hostess collector. The platform injects
the endpoint (
HOSTESS_OTEL_ENDPOINT); override withotlp_endpoint=for local use. - Emits a periodic marker heartbeat so Studio can tell "installed, waiting for traffic" from "not installed".
- Idempotent and fail-silent: bounded export queue, no added request latency,
never crashes the host app. A clean no-op when disabled (
enabled=FalseorHOSTESS_INSTRUMENTATION=false) or when no collector endpoint is available.
instrument(
app,
enabled=None, # None → env (HOSTESS_INSTRUMENTATION), default on
service_name=None, # defaults to the platform-injected name
exclude_paths=["/health"],
otlp_endpoint=None, # local/advanced override
)The helper collects HTTP method, route template, status code, and duration. It never collects request/response bodies, query strings, raw URLs, headers, cookies, tokens, user IDs, or client IPs.
uv sync --extra fastapi
uv run pytest -q