Files
backend/.ai/conventions/observability.md
T
ksv741 d698ed9425
Backend verify / commits (pull_request) Successful in 29s
Backend verify / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Failing after 9m36s
refactor!: simplify runtime coordination #7
Keep financial ownership, atomic publication and refresh CAS.
Failed refresh leaves cookies untouched; logout still clears them.

Remove full-history candle prefetch and special metadata retries.
Use native Pino request context instead of parallel middleware.

BREAKING CHANGE: remove investment stateVersion, queued sync state,
and tbank-sync status progress/resources. Consumers must observe
resources through sync=observe with the updated frontend contract.
2026-10-03 11:38:08 +03:00

2.1 KiB

Observability

  • Единственный logger — nestjs-pino. Application events используют StructuredLogger, стабильное имя события и разрешённые scalar fields. console.log и второй logger в production не используются.
  • info — значимый lifecycle/outcome; debug — подробности успешного RPC; warn — восстановимая проблема/retry; error — окончательный сбой. Не добавляй log на каждый вход/выход функции или дубликат HTTP completion.
  • Native nestjs-pino context и pino-http completion владеют correlation: server request ID возвращается как X-Request-ID, client ID хранится отдельно. Настройки принадлежат common/logging/logging.module.ts; второй AsyncLocalStorage или HTTP completion middleware не нужен. Передавай существующий context, не создавай собственный UUID в каждом service.
  • StructuredLogger ограничивает поля, Pino redacts request secrets. Не логируй passwords, tokens, cookie, Authorization, credentials, connection generation, raw body или upstream error. Secret в message/stack не становится безопасным из-за allowlist; правила Security обязательны для sensitive data.
  • Для ошибки используй public code и безопасный context операции/попыток; error mapping не отдаёт внутренние детали клиенту.

Проверяй новые поля/redaction/correlation existing logging tests; не добавляй тест на каждую строку log. Existing ESLint не запрещает все вызовы console отдельным правилом: до настройки встроенного no-console это semantic review.