Skip to main content
For advanced use cases, you can work directly with the Client class. This gives you full control over initialization, trace submission, scoring, and lifecycle management.
We do not recommend using the low-level client API for normal tracing. You must manually construct traces and spans that match the standard PandaProbe schema, and the API endpoints expect that schema. Use wrappers, integrations, or decorators unless you have an advanced use case that needs direct client control.

Programmatic initialization

pandaprobe.init() parameters: Returns the configured Client instance and sets it as the global singleton.
If init() is called when a client already exists, the existing client is shut down and replaced.

Creating traces via Client

client.trace() has the same signature as pandaprobe.start_trace().
Use get_client() after init() when you inject dependencies in tests or pass the client through your application layer.

Submitting pre-built traces

Use pre-built TraceData when traces are assembled offline, replayed from logs, or produced by frameworks that already materialize a full trace object.

Scoring

Lifecycle management

Always call flush() before shutdown() in short-lived scripts. For long-running services, the SDK flushes automatically via a background thread and atexit handler.

Error handling

Register callbacks to be notified of transport errors:

Properties

  • client.enabledbool, whether the SDK is active
  • client.configSdkConfig, the resolved configuration (frozen dataclass)

Auto-initialization

The global client auto-initializes from environment variables on first use. You only need to call pandaprobe.init() if you want to configure the SDK programmatically or override environment variables.
pandaprobe.get_client() returns None if auto-init fails (e.g., missing API key). pandaprobe.start_trace() raises RuntimeError if no client is available.