Skip to main content
For advanced use cases, you can work directly with the Python or TypeScript 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.

Python client API

Programmatic initialization

Python
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().
Python
Use get_client() after init() when you inject dependencies in tests or pass the client through your application layer.

Submitting pre-built traces

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

Scoring

Python

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:
Python

Properties

  • client.enabled — bool, whether the SDK is active
  • client.config — SdkConfig, 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.
Python
pandaprobe.get_client() returns None if auto-init fails (e.g., missing API key). pandaprobe.start_trace() raises RuntimeError if no client is available.

TypeScript client API

Programmatic initialization

TypeScript
The TypeScript client uses camelCase option names. init() sets and returns the global singleton. getClient() returns that client or attempts one-time initialization from environment variables.

Creating traces with a client

TypeScript
For application code, prefer withTrace() and withSpan(); they provide the same callback lifecycle with less client plumbing.

Submitting pre-built traces

TypeScript

Scoring and lifecycle

TypeScript
The enabled and config properties expose the resolved client state. TypeScript configuration is frozen after initialization; call init() again to replace the global client.