Skip to main content
Call tracing.init() once at startup. Wrap each unit of work in tracing.turn() for the session and tracing.agent() for the agent doing the work. Every span opened inside them carries botgauge.session.id, botgauge.turn.id, botgauge.agent.id, and botgauge.agent.revision.id.
quickstart.py

API summary

init() accepts arguments that override the environment, including api_key, endpoint, headers, capture, redacted, tracer_provider, sample_ratio, and capture_allow_keys. Arguments always win over environment variables, for example tracing.init(api_key=..., endpoint=...).

How init() picks its settings

With no arguments, init() reads BOTGAUGE_API_KEY. With only a key set, it sends to https://api.botgauge.com/v1/traces. Set BOTGAUGE_ENDPOINT to send to a different collector. The key goes out only as Authorization: Bearer <key>, and the body is gzip-compressed OTLP protobuf. If you pass your own Authorization header in headers=, it replaces the key. init() does not read .env files, so load yours first. See Get your API key. It also never reads OTEL_EXPORTER_OTLP_* variables.
With neither a key nor an endpoint, init() prints botgauge: no endpoint configured; BotGauge export disabled. to stderr and sends nothing. For local debugging, set BOTGAUGE_CONSOLE_EXPORT=1 to print spans to stdout instead.

Rejected keys never crash your app

Export runs on a background thread. On the first 401 or 403, the SDK logs one line, botgauge: BotGauge rejected the API key (401 ...), which asks you to check the key. If you passed your own Authorization header in headers=, the line names that header instead, because it replaces the key. If you set an endpoint but no key, the message says no credential was sent. BotGauge reports problems as warnings on the standard Python logger named botgauge, so you can route or silence them like any other logger.

Already using OpenTelemetry

tracing.init() attaches to your existing tracer provider instead of replacing it, so spans from your own instrumentation reach BotGauge too, with the same privacy masking. To attach a framework instrumentor in code, pass the provider that init() returns.
app.py
Each framework page shows the exact instrumentor to use. See supported frameworks.

Wrap your first turn and agent

Sign in to BotGauge to create a key, then add tracing.init() to your app.

Try BotGauge →

Sampling

When BotGauge creates the provider and you don’t pass sample_ratio=, it honors the standard OTEL_TRACES_SAMPLER variables, so a sampler configured for another tool also samples BotGauge’s traces. BotGauge prints a one-time warning at startup when it will drop traces. Pass sample_ratio=1.0 to record everything regardless. See environment variables for the full list.