References
Classes
Use these classes to handle trace data in the watsonx Orchestrate platform.Import example
TracesController
TracesController
Use Returns:Returns:Returns:
TracesController to access trace operations programmatically in the watsonx Orchestrate observability platform.
It exposes methods to search, fetch, and export traces, with optional pagination and CLI-oriented progress logging.Methods
get_client(self) -> TracesClient
Return the underlyingTracesClient, creating it if necessary.Returns:An authenticated client bound to the active environment.
fetch_trace_observations(self, trace_id: str, page_size: int = 100, fetch_all: bool = True, show_progress: bool = False) -> ObservationsExportResponse
Fetch all observations for a specific trace ID.Parameters:string
A trace ID.
int
Number of observations per page (1–1000). Default is
100.bool
When
True, retrieves observations across all pages automatically. Default is True.bool
When
True, logs progress through the logger. Default is False.Contains
observations (list of Observation objects), totalCount, page, and totalPages.export_trace_to_json(self, trace_id: str, output_file: Optional[str] = None, pretty: bool = True, page_size: int = 50) -> tuple[ObservationsExportResponse, str]
Fetch observations for a trace ID and serialize them to JSON. Optionally writes the output to a file.Parameters:string
A trace ID.
string (optional)
A file path for the JSON output. When
None, JSON is returned as a string only. Default is None.bool
Indented JSON for readability. Default is
True.int
Number of observations per page. Default is
50.- ObservationsExportResponse: The observations fetched, for programmatic use.
- string: The JSON output, suitable for display or storage.
search_traces(self, filters: Optional[TraceFilters] = None, sort: Optional[TraceSort] = None, page_size: int = 100, show_progress: bool = False) -> TraceSearchResponse
Search for traces using optional filters and sort options.Parameters:TraceFilters (optional)
Search criteria. Supported fields:
start_time— ISO 8601 string ordatetimeend_time— ISO 8601 string ordatetimeuser_ids— list of user IDs (only the first value is used by the API)session_ids— list of session IDs (only the first value is used by the API)
None (returns all traces up to page_size).TraceSort (optional)
Sorting options. Use
field="start_time" and direction="asc" or direction="desc". The values "start_time" and "end_time" both map to "timestamp" at the API level.
Default is None.int
Results per page (1–1000). Default is
100.bool
When
True, logs progress messages via logger. Default is False.Contains
traces (list of TraceItem), traceSummaries, totalCount, and meta (pagination).Models
Use these models and the client to work with trace data in the watsonx Orchestrate platform.Import example
Observation
Observation
Represents a single recorded step within a trace. The API returns this object from
GET /v1/agentops-v3/observations.Attributesstring
Observation ID.
string
Parent trace ID.
string
Observation type, for example
GENERATION.string
Observation name.
string
Start time (ISO 8601).
string | None
End time (ISO 8601). May be
None for in-progress observations.string | None
LLM model used, if applicable.
dict | list | string | None
Input data passed to the operation.
dict | list | string | None
Output data returned from the operation.
dict | None
Arbitrary metadata.
dict | None
Token usage statistics.
ObservationsExportResponse
ObservationsExportResponse
The response object that
fetch_trace_observations() and export_trace_to_json() return.Attributeslist[Observation] | None
List of observations for the trace.
int | None
Total number of observations reported by the API. Also accessible as the
total_count property.int | None
Current page number.
int | None
Total number of pages.
TraceItem
TraceItem
Represents a single trace entry. The API returns this object from
GET /v1/agentops-v3/traces.Attributesstring
Trace ID.
string | None
Trace name.
string
Trace start time (ISO 8601).
string | None
Session ID associated with the trace.
string | None
User ID associated with the trace.
list[string] | None
Tags attached to the trace.
float | None
Trace duration in seconds.
dict | list | string | None
Input data for the trace.
dict | list | string | None
Output data for the trace.
dict | None
Arbitrary metadata.
TraceFilters
TraceFilters
Defines search criteria for trace queries. All fields are optional.Attributes
string | datetime
Start of the time range. Accepts an ISO 8601 string or a Python
datetime object.string | datetime
End of the time range. Accepts an ISO 8601 string or a Python
datetime object.list[string]
Filter by user ID. Only the first value in the list is sent to the API.
list[string]
Filter by session ID. Only the first value in the list is sent to the API.
TraceSort
TraceSort
TraceSummary
TraceSummary
Provides summary data for a trace. The
TraceSearchResponse.traceSummaries list contains these objects.Attributesstring
Trace ID.
string
Trace start time (ISO 8601).
Note:The agentops-v3 API does not return separate start and end times for agent traces. Both
startTime and endTime are populated from the same timestamp field returned by the API. Dedicated start/end time values may become available in a future API update.string
Trace end time (ISO 8601).
Note:The agentops-v3 API does not return separate start and end times for agent traces. Both
startTime and endTime are populated from the same timestamp field returned by the API. Dedicated start/end time values may become available in a future API update.float
Trace duration in milliseconds.
list[string] | None
Agent IDs extracted from trace metadata.
list[string] | None
Agent names extracted from trace metadata.
list[string] | None
User IDs associated with the trace.
list[string] | None
Session IDs associated with the trace.
TraceSearchResponse
TraceSearchResponse
The response object that
search_traces() returns.Attributeslist[TraceItem] | None
List of trace items from the agentops-v3 API.
list[TraceSummary]
Summary view of each trace, derived from the trace items.
int | None
Total number of matching traces.
PaginationMeta | None
Pagination metadata.
string
Time the response object was created.
object
The query parameters that were sent to the API.

