get_current_span_id()

Signature

get_current_span_id() -> Optional[str]

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

Example

from respan import Respan, get_client, task
respan = Respan(api_key="your-api-key")
@task(name="span_demo")
def span_demo():
client = get_client()
span_id = client.get_current_span_id()
print(f"Span ID: {span_id}") # e.g. "00f067aa0ba902b7"
return span_id
span_demo()