get_current_trace_id()

Signature

get_current_trace_id() -> Optional[str]

Returns the current trace ID as a 32-character hex string, or None when no span is active.

Example

from respan import Respan, get_client, workflow
respan = Respan(api_key="your-api-key")
@workflow(name="trace_demo")
def trace_demo():
client = get_client()
trace_id = client.get_current_trace_id()
print(f"Trace ID: {trace_id}") # e.g. "0af7651916cd43dd8448eb211c80319c"
return trace_id
trace_demo()