Ends a trace (its root span) and finalizes it. If no trace_context is provided, ends all active session spans. Args: trace_context: The TraceContext object returned by start_trace. If None, ends all active traces. end_state: The final state of the trace (e.g., "Success"
(
trace_context: Optional[TraceContext] = None, end_state: Union[TraceState, StatusCode, str] = TraceState.SUCCESS
)
| 256 | |
| 257 | |
| 258 | def end_trace( |
| 259 | trace_context: Optional[TraceContext] = None, end_state: Union[TraceState, StatusCode, str] = TraceState.SUCCESS |
| 260 | ) -> None: |
| 261 | """ |
| 262 | Ends a trace (its root span) and finalizes it. |
| 263 | If no trace_context is provided, ends all active session spans. |
| 264 | |
| 265 | Args: |
| 266 | trace_context: The TraceContext object returned by start_trace. If None, ends all active traces. |
| 267 | end_state: The final state of the trace (e.g., "Success", "Indeterminate", "Error"). |
| 268 | """ |
| 269 | if not tracer.initialized: |
| 270 | logger.warning("AgentOps SDK not initialized. Cannot end trace.") |
| 271 | return |
| 272 | tracer.end_trace(trace_context=trace_context, end_state=end_state) |
| 273 | |
| 274 | |
| 275 | def update_trace_metadata(metadata: Dict[str, Any], prefix: str = "trace.metadata") -> bool: |
nothing calls this directly
no test coverage detected
searching dependent graphs…