is_recording()

Signature

is_recording() -> bool

Returns True if there is an active span that is recording, False otherwise.

Example

from respan import Respan, task, get_client
respan = Respan(api_key="your-api-key")
@task(name="guarded_task")
def guarded_task():
client = get_client()
if client.is_recording():
client.add_event("task_running")
return "done"
guarded_task()