get_current_span_id()

Signature

1get_current_span_id() -> Optional[str]

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

Example

1from respan import Respan, get_client, task
2
3respan = Respan(api_key="your-api-key")
4
5@task(name="span_demo")
6def span_demo():
7 client = get_client()
8 span_id = client.get_current_span_id()
9 print(f"Span ID: {span_id}") # e.g. "00f067aa0ba902b7"
10 return span_id
11
12span_demo()