components.Trace
Trace functionality for Components integration.
TraceConfig
Trace config.
This class represents a trace config.
TraceConfigDict
Trace config dict.
This class represents a trace config dictionary.
get_trace_config_dict
Convert a TraceConfig object to a TraceConfigDict.
Arguments:
Name | Description |
---|---|
config | Either a TraceConfig object or a TraceConfigDict dictionary. |
Returns:
A TraceConfigDict dictionary representation of the config.
Trace
A class representing a trace in the logging system.
A trace is a high-level container for tracking a complete operation or workflow.
__init__
Initialize a new Trace instance.
Arguments:
Name | Description |
---|---|
config | Configuration for the trace, either as a TraceConfig object or a TraceConfigDict. |
writer | The LogWriter instance to use for writing log entries. |
set_input
Set the input for this trace.
Arguments:
Name | Description |
---|---|
input | The input string to set. |
set_input_
Static method to set the input for a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to update. |
input | The input string to set. |
set_output
Set the output for this trace.
Arguments:
Name | Description |
---|---|
output | The output string to set. |
set_output_
Static method to set the output for a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to update. |
output | The output string to set. |
generation
Add a generation to this trace.
Arguments:
Name | Description |
---|---|
config | Configuration for the generation. |
Returns:
A new Generation instance.
tool_call
Add a tool call to this trace.
Arguments:
Name | Description |
---|---|
config | Configuration for the tool call. |
Returns:
A new ToolCall instance.
tool_call_
Static method to add a tool call to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the tool call to. |
config | Configuration for the tool call. |
Returns:
A new ToolCall instance.
generation_
Static method to add a generation to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the generation to. |
config | Configuration for the generation. |
Returns:
A new Generation instance.
add_error
Add an error to this trace.
Arguments:
Name | Description |
---|---|
config | Configuration for the error. |
Returns:
A new Error instance.
error_
Static method to add an error to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the error to. |
config | Configuration for the error. |
Returns:
A new Error instance.
retrieval
Add a retrieval to this trace.
Arguments:
Name | Description |
---|---|
config | Configuration for the retrieval. |
Returns:
A new Retrieval instance.
retrieval_
Static method to add a retrieval to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the retrieval to. |
config | Configuration for the retrieval. |
Returns:
A new Retrieval instance.
span
Add a span to this trace.
Arguments:
Name | Description |
---|---|
config | Configuration for the span. |
Returns:
A new Span instance.
span_
Static method to add a span to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the span to. |
config | Configuration for the span. |
Returns:
A new Span instance.
feedback
Add feedback to this trace.
Arguments:
Name | Description |
---|---|
feedback | The feedback to add. |
feedback_
Static method to add feedback to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the feedback to. |
feedback | The feedback to add. |
add_tag_
Static method to add a tag to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to add the tag to. |
key | The tag key. |
value | The tag value. |
add_attachment
Add an attachment to this trace.
Arguments:
Name | Description |
---|---|
attachment | The attachment to add. |
add_attachment_
Static method to add an attachment to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the attachment to. |
attachment | The attachment to add. |
end_
Static method to end a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to end. |
data | Additional data to include in the end event. |
Returns:
The result of the end operation.
event_
Static method to add a custom event to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the event to. |
id | The ID of the event. |
event | The name of the event. |
tags | Optional tags to associate with the event. |
metadata | Optional metadata to include with the event. |
Returns:
The result of the event operation.
data
Get the data representation of this trace.
Returns:
A dictionary containing the trace data.