Before you start
- Python 3.9 or later
- A Kubit workspace and its ingestion API key (see below)
- An agent that calls an LLM, or any Python script to test with
Prompt for your coding agent
Paste this into Claude Code, Cursor or Codex in your repo:Steps
Get an API key
Kubit authenticates spans with an ingestion API key, read from the
KUBIT_API_KEY environment variable. Each key belongs to one workspace.Then set it in your shell for the next steps:
Install the SDK
.env with python-dotenv, keep using it. Kubit reads KUBIT_API_KEY from the environment either way.Add the bootstrap file
Create Change
kubit_instrumentation.py next to your entrypoint:kubit_instrumentation.py
service_name, service_version and deployment.environment to match your app. Kubit uses them to tell agents and releases apart.Import it first in your entrypoint
Make it the first import in
main.py, app.py or whichever file starts your app, so the provider exists before any LLM client is created:main.py
Send a test span
From the folder that holds The two-second sleep gives the exporter time to send the span before the process exits.
kubit_instrumentation.py, run:Verify
Check that thehello-kubit span arrived. With the Kubit MCP server connected in Claude Code or Cursor, ask:
“Show me traces from the last 15 minutes”The result lists a trace whose root span is named
hello-kubit, from service support-agent.
In the Kubit app:
If it fails
More checks are in Is my data flowing?.
Next steps
- Send traces from Python: existing providers, frameworks and production settings.
- Span attributes: add user and session IDs so Kubit can group traces.
- Concepts: what Polaris does with the spans you just sent.