Define Resilience Request Recorder Types and Context
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Motivation
The resilience decorator pattern needs request-level recording to track success/failure of operations per request. Following the sokovan scheduler recorder pattern, we need ContextVar-based recorder management.
- No way to track resilience operation outcomes per request
- Cannot aggregate success/failure information for a single request across multiple operations
## Required Features
- Create `RequestRecord` dataclass to store operation result (name, status, duration, error)
- Create `RequestRecorder` class to collect records for a request
- Methods: `record_success()`, `record_failure()`, `get_records()`
- Create `RequestRecorderContext` class with ContextVar management
- Class methods: `scope()`, `current()`, `try_current()`
- Follow patterns from `src/ai/backend/manager/sokovan/scheduler/recorder/`
## Impact
- New files: `src/ai/backend/common/resilience/recorder/`
- `__init__.py`
- `types.py`
- `recorder.py`
- `context.py`
## Testing Scenarios
- Test RequestRecorder collects records correctly
- Test RequestRecorderContext.scope() creates isolated contexts
- Test nested scopes work correctly
- Test context access outside scope raises appropriate error
JIRA Issue: BA-3728
Contributor guide
Assessment
This issue has not been assessed yet.