The trace.py module#
Summary#
Return a new 12-character trace id. |
|
Return the trace id of the tool call running in this context. |
|
Make |
|
Restore the trace id that was current before |
|
Log one line for a finished tool call. |
Description#
Per-call trace ids so host-side and server-side logs line up.
Every wrapped tool call gets a short trace id. The server logs one line per
call (tool, trace id, duration, outcome); error results carry the id as
trace_id; code running inside the call can read current_trace_id().
Module detail#
- trace.bind_trace_id(trace_id: str) contextvars.Token[str | None]#
Make
trace_idthe current trace id.- Parameters:
- trace_id
str Trace id of the call that is starting.
- trace_id
- Returns:
contextvars.Token[str|None]Token to pass to
reset_trace_id()when the call ends.
- trace.reset_trace_id(token: contextvars.Token[str | None]) None#
Restore the trace id that was current before
bind_trace_id().- Parameters:
- token
contextvars.Token[str|None] Token returned by
bind_trace_id().
- token