References
Classes
Use these classes to handle trace data in the watsonx Orchestrate platform.Import example
TracesController
TracesController
Use 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: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:Returns: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:A file path for the JSON output. When
None, JSON is returned as a string only. Default is None.- 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: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).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.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.AttributesObservationsExportResponse
ObservationsExportResponse
The response object that
fetch_trace_observations() and export_trace_to_json() return.AttributesTotal number of observations reported by the API. Also accessible as the
total_count property.TraceItem
TraceItem
Represents a single trace entry. The API returns this object from
GET /v1/agentops-v3/traces.AttributesTraceFilters
TraceFilters
Defines search criteria for trace queries. All fields are optional.Attributes
TraceSort
TraceSort
TraceSummary
TraceSummary
Provides summary data for a trace. The
TraceSearchResponse.traceSummaries list contains these objects.AttributesTrace 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.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.TraceSearchResponse
TraceSearchResponse
The response object that
search_traces() returns.Attributes
