Skip to main content

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_tracing import RespanTelemetry, get_client, task

telemetry = RespanTelemetry(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()