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
SpanType value: SPAN, GENERATION, EVENT, AGENT, TOOL, CHAIN, RETRIEVER, EVALUATOR, EMBEDDING, GUARDRAIL. See Span Types for details. An unrecognized value emits a UserWarning and is sent as SPAN, so your original label is not stored. Pass the label to spans.create instead when you need Galtea to keep it.
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 span description (max 1MB). Default: False.

Features

Automatic Exception Recording

Exceptions are always recorded in spans 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

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