Python decorators
@pandaprobe.trace
Creates a new trace for the decorated function. Use this on your top-level entry points.
Can be used with or without parentheses:
- Input: Automatically captured from function arguments (uses
inspect.signatureto build a JSON-friendly dict). - Output: Automatically captured from the return value.
- At the trace level, the SDK extracts only the last user message from input and the last assistant message from output.
Why trace-level message extraction?
Why trace-level message extraction?
Trace views often focus on the conversational turn. Full structured arguments remain available in raw span data when you need deeper inspection.
@pandaprobe.span
Creates a new span within the current trace. Use this on inner functions.
Python
Sync and async support
Both decorators auto-detect sync vs async functions and wrap accordingly.- Sync
- Async
Python
Nesting
Python
Trace("support-agent") → Span("retrieve", RETRIEVER) → Span("generate", LLM).
Combining with wrappers
Python
No-op behavior
If the SDK is disabled (PANDAPROBE_ENABLED=false) or no client is available, both decorators pass through transparently: the decorated function runs normally with no overhead.
No-op mode is intentional for local development and tests where you omit API keys or disable tracing globally.
TypeScript decorators
Importtrace, span, and SpanKind from the base package. Both current Stage 3 decorators and legacy TypeScript decorator emit are supported.
TypeScript
TypeScript trace options
TypeScript span options
For input capture, a single object argument is preserved as-is; other argument lists are stored under
args. Return values become span outputs. The trace decorator extracts the last user and assistant messages when the standard messages shape is used.
Like Python, @span runs without instrumentation when there is no active trace, and both decorators pass through when PandaProbe is disabled or unconfigured.
