Skip to main content

Returns

Returns the decorated function with automatic tracing enabled.

Example

Parameters

string
Custom span name. Defaults to the function name.
string
TraceType value: SPAN, GENERATION, EVENT, AGENT, TOOL, CHAIN, RETRIEVER, EVALUATOR, EMBEDDING, GUARDRAIL. See Trace Types for details. An unrecognized value emits a UserWarning and is still sent as-is, so values added in newer API versions can be used without upgrading the SDK.
bool
Whether to log function arguments as input data. Default: True.
bool
Whether to log return value as output data. Default: True.
dict
Custom attributes to add to the span (e.g., model name, configuration).
bool
If True, the function’s docstring is automatically used as the trace description (max 1MB). Default: False.

Features

Automatic Exception Recording

Exceptions are always recorded in traces for debugging, regardless of log_args and log_results settings:

Input/Output Serialization

Function arguments and return values are automatically serialized to JSON. Non-serializable objects are converted to string representation:

Context Propagation

Traces automatically inherit the context set by set_context():
The @trace decorator uses OpenTelemetry under the hood. Traces are automatically exported to Galtea API when clear_context() is called or when the batch processor flushes.