Overview
isRecording() returns whether the current span is active and recording. Useful for conditional tracing logic or debugging.
Signature
Basic Usage
Conditional Event Adding
Debug Logging
Performance Metrics
Outside of Traced Functions
Sampling Logic
Return Value
Returnstrue if tracing is currently active and recording, false otherwise.
Best Practices
- Use to conditionally add expensive tracing operations
- Check before adding numerous events in loops
- Useful for debug logging that should only happen during tracing
- Safe to call from any context (traced or untraced)
- Can be used to implement custom sampling logic
- Helps avoid overhead when tracing is disabled