Files
specs/openspec/changes/archive/2026-08-14-add-backend-structured-logging/tasks.md
T
2026-08-14 17:19:10 +03:00

26 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1. Базовый logger и конфигурация
- [x] 1.1 Добавить валидируемый `LOG_LEVEL`, его production default и пример в backend-конфигурацию.
- [x] 1.2 Добавить `nestjs-pino`, настроить JSON stdout, уровни debug/info/warn/error, redaction и allowlisted HTTP serializers.
- [x] 1.3 Подключить Pino к Nest bootstrap с lifecycle-событиями запуска и штатного завершения.
## 2. Контекст и HTTP-события
- [x] 2.1 Добавить request context на `AsyncLocalStorage`: server-generated request ID, безопасный client request ID и `X-Request-ID` response header.
- [x] 2.2 Настроить CORS для чтения `X-Request-ID` browser-клиентом.
- [x] 2.3 Добавить единственное HTTP completion-событие с безопасным route template, duration и уровнем по outcome.
- [x] 2.4 Передавать public error code и stack 5xx из exception filter в completion-событие без изменения problem response.
## 3. Миграция backend-событий
- [x] 3.1 Перевести T-Bank client на allowlisted success/retry/failure события с duration, gRPC code и attempts.
- [x] 3.2 Перевести существующие Portfolio и Upcoming Events события на Pino logger и удалить прямой `Nest Logger`.
- [x] 3.3 Добавить внутренние user ID и brokerage account ID в контекст только в местах, где они уже доступны.
## 4. Проверка
- [x] 4.1 Добавить unit-тесты logger и config validation для уровней, JSON-формата и отсутствия запрещённых полей.
- [x] 4.2 Добавить backend e2e-тесты `X-Request-ID`, CORS, одного completion-события, 5xx error code/stack и безопасной деградации logging failure.
- [x] 4.3 Добавить тесты T-Bank client для уровней success/retry/final failure и correlation context.
- [x] 4.4 Выполнить `npm run lint`, `npm test`, `npm run build` в backend и `openspec validate add-backend-structured-logging --type change --store wealth-ledger-specs`.