FastAPI

ASGI middleware, so background tasks are attributed too.

“Webhook dispatcher” already reports from here. Another one gets its own write key and lands in the same table.Open

Take the write key

Everything this install sends is tagged with it, so one key per environment keeps staging out of your production numbers.

Generating…

Install

One package, in the service you are instrumenting.

pip install clearplane

Add it to FastAPI

Paste this where the request path is assembled. The account callback is the only part you have to fill in — it is what turns a request into a customer.

python
from clearplane.fastapi import ClearplaneMiddleware

app.add_middleware(
    ClearplaneMiddleware,
    write_key=os.environ["CLEARPLANE_KEY"],
    account=lambda request: request.state.org_id,
)

Name this install

Name it for the deployment rather than the framework. Two Next.js apps in one workspace is the normal case, and “Next.js” twice helps nobody.

Environment

Events land in events_fastapi and are queryable from Chat, models, and SQL.