Skip to content

Repository files navigation

hostess-python

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.

What instrument(app) does

  • 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 with otlp_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=False or HOSTESS_INSTRUMENTATION=false) or when no collector endpoint is available.

Options

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
)

Privacy

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.

Development

uv sync --extra fastapi
uv run pytest -q

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages