Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.pandaprobe.com/llms.txt

Use this file to discover all available pages before exploring further.

While environment variables are the recommended way to configure PandaProbe, you can also configure the SDK programmatically using pandaprobe.init().

Basic programmatic configuration

import pandaprobe

pandaprobe.init(
    api_key="your-api-key",
    project_name="my-project",
    endpoint="https://api.pandaprobe.com",
    environment="production",
    release="v1.2.3",
)

Precedence rules

Parameters passed to pandaprobe.init() always take precedence over environment variables:
# Even if PANDAPROBE_ENDPOINT is set in the environment,
# this will use the explicitly provided endpoint:
pandaprobe.init(
    endpoint="https://custom-endpoint.com",
)
Precedence order (highest to lowest):
  1. Explicit keyword arguments to pandaprobe.init()
  2. PANDAPROBE_* environment variables
  3. SDK defaults

SdkConfig fields

The resolved configuration is stored as a frozen SdkConfig dataclass. You can inspect it via the client:
client = pandaprobe.init(api_key="...", project_name="...")
print(client.config.endpoint)       # "https://api.pandaprobe.com"
print(client.config.batch_size)     # 10
print(client.config.flush_interval) # 5.0
FieldTypeDefault
api_keystr | NoneNone
project_namestr | NoneNone
endpointstr"https://api.pandaprobe.com"
environmentstr | NoneNone
releasestr | NoneNone
enabledboolTrue
batch_sizeint10
flush_intervalfloat5.0
max_queue_sizeint1000
debugboolFalse
When enabled=True, both api_key and project_name are required. The SDK raises ValueError at initialization if either is missing.

Re-initialization

Calling pandaprobe.init() when a client already exists shuts down the previous client and creates a new one:
pandaprobe.init(project_name="project-a")
# ... traces go to project-a ...

pandaprobe.init(project_name="project-b")
# ... traces now go to project-b ...

Auto-initialization

If you don’t call pandaprobe.init(), the SDK auto-initializes from environment variables on first use:
# No init() call needed if env vars are set:
with pandaprobe.start_trace("my-trace") as t:
    ...
Auto-initialization is attempted once. If it fails (for example, missing API key), subsequent calls to get_client() return None and convenience functions like flush() and shutdown() silently no-op.