MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / end_trace

Function end_trace

agentops/__init__.py:258–272  ·  view source on GitHub ↗

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
)

Source from the content-addressed store, hash-verified

256
257
258def 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
275def update_trace_metadata(metadata: Dict[str, Any], prefix: str = "trace.metadata") -> bool:

Callers

nothing calls this directly

Calls 1

end_traceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…