get_client()
get_client()
Overview
get_client() returns a RespanClient instance bound to the singleton tracer. Use it inside decorated functions to read trace/span IDs, update the current span, add events, record exceptions, and control export.
get_client()
get_client() returns a RespanClient instance bound to the singleton tracer. Use it inside decorated functions to read trace/span IDs, update the current span, add events, record exceptions, and control export.
1 from respan import get_client
1 from respan import Respan, get_client, workflow 2 3 respan = Respan(api_key="your-api-key") 4 5 @workflow(name="my_workflow") 6 def my_workflow(): 7 client = get_client() 8 9 # Read IDs 10 trace_id = client.get_current_trace_id() 11 span_id = client.get_current_span_id() 12 13 # Update span 14 client.update_current_span( 15 respan_params={"customer_identifier": "user-123"} 16 ) 17 18 # Add events 19 client.add_event("processing_started", {"items": 10}) 20 21 return trace_id 22 23 print(my_workflow())
| Method | Description |
|---|---|
get_current_trace_id() | Get active trace ID as hex string. |
get_current_span_id() | Get active span ID as hex string. |
update_current_span() | Update attributes, status, and Respan params on the current span. |
add_event() | Add a timestamped event to the current span. |
record_exception() | Record an exception on the current span. |
get_context_value() | Read a value from the OpenTelemetry context. |
set_context_value() | Set a value in the OpenTelemetry context. |
is_recording() | Check if the current span is recording. |
get_tracer() | Get the OpenTelemetry tracer for manual span creation. |
flush() | Force flush pending spans. |
get_span_buffer() | Get a span buffer for manual batch collection. |
process_spans() | Process collected spans through the processor pipeline. |