Перейти к основному содержимому

Observability И Наблюдаемость

Цели

  • Сделать каждую финансовую операцию, provider callback, KYC decision, admin action и partner payout трассируемыми.
  • Обнаруживать broken callbacks, stuck MassTransit outbox, Kafka lag, failed payments, provider degradation и tenant boundary violations.
  • Не допускать попадания PII/secrets в logs, traces, metrics и error trackers.
  • Сделать observability обязательной частью постановки задачи, а не технической доработкой после реализации.

Обязательство Для Операций

Каждая операция в документации описывает:

  • logs: вход, ключевые шаги, controlled errors и unexpected errors;
  • metrics: latency, error rate, throughput;
  • tracing: correlationId, traceId, causationId для event/callback flows;
  • audit: actor, action, entity id, before/after fields для admin/security/money решений.

Если операция критична для денег, KYC, identity, provider callbacks или withdrawals, отсутствие observability секции блокирует Definition of Ready.

Обязательные dashboards, SLO, alerts, owners и runbook requirements описаны в Operational Dashboard Catalog.

Сигналы

Логи

Используются structured Serilog logs:

  • timestamp
  • level
  • messageTemplate
  • service
  • environment
  • tenantId
  • brandId
  • actorId
  • actorType
  • correlationId
  • traceId
  • requestId
  • route
  • operation

Трейсы

Инструментируются:

  • gateway request;
  • controllers/actions;
  • MediatR handlers;
  • EF Core queries/transactions;
  • HTTP clients;
  • Kafka publish/consume;
  • Redis;
  • provider adapters;
  • file storage calls.

Метрики

MetricPurpose
http_server_durationAPI latency.
http_requests_totalAPI traffic/errors.
kafka_consumer_lagConsumer delay.
masstransit_outbox_pending_countStuck/unpublished events через MassTransit outbox.
masstransit_inbox_duplicate_countDuplicate event volume через MassTransit inbox.
accounting_ledger_posting_durationFinancial posting latency.
accounting_hold_active_amountHeld withdrawal amount.
payment_callback_failure_countPayment provider failures.
game_callback_latencyProvider callback latency.
game_callback_error_rateProvider callback error rate.
identity_login_failure_rateBrute force/fraud signals.
kyc_review_queue_sizeCompliance backlog.
incentive_redemption_failure_countIncentive issues.

Нейминг Операционных Метрик

ТипФорматПример
Latency<service>_<operation>_duration_msaccounting_create_deposit_duration_ms
Throughput<service>_<operation>_requests_totalkyc_approve_verification_requests_total
Errors<service>_<operation>_errors_totalexecution_gateway_external_integrator_request_errors_total
State transition<service>_<entity>_<from>_to_<to>_totalaccounting_withdrawal_requested_to_approved_total
Queue/backlog<service>_<queue>_pending_countaccounting_masstransit_outbox_pending_count

Metric labels должны быть bounded: service, operation, tenantTier, providerCode, status, errorCode. Нельзя использовать raw user id, email, phone, document id или unbounded external reference как label.

Correlation Flow

  • Gateway создает correlationId, если клиент не передал валидный id.
  • Backend service принимает correlationId из headers, кладет его в log scope, trace baggage и event envelope.
  • MassTransit event через MassTransit outbox сохраняет correlationId и causationId в envelope/headers.
  • Consumer переносит correlationId в downstream logs, traces, metrics exemplars и external calls.
  • Frontend сохраняет correlationId из response headers для support diagnostics, но не показывает raw technical details пользователю.

Единые правила propagation: Execution Context Propagation. Единый API middleware/filter pipeline: API Middleware And Filters Standard.

Черновик SLO

SLOTarget
Public API availability99.9%
Accounting posting availability99.95%
Accounting posting p95 latency< 300 ms
Provider callback p95 latency< 500 ms
Deposit callback processing p95< 2 s
MassTransit outbox publish delay p95< 30 s
Kafka consumer lag recovery< 5 min
Admin panel availability99.5%

Sentry

  • Enable backend and frontend Sentry.
  • Scrub PII, tokens, payment credentials and provider secrets.
  • Tag errors with tenant/service/domain where safe.
  • Use higher sampling for accounting, payments, game callbacks and KYC errors.
  • Release tracking must include git sha/build version.

Группы Алертов

GroupExamples
Finance criticalAccounting posting failures, negative balance invariant, stuck withdrawals.
Provider callbacksSignature failures spike, callback latency, duplicate external refs spike.
SecurityLogin failure spike, MFA failures, tenant boundary violation, permission changes.
PipelineKafka lag, MassTransit outbox stuck, DLQ growth.
InfrastructurePostgreSQL/Redis/Kafka/Elasticsearch/ClickHouse health.

Требования К Runbook

Every critical alert needs:

  • impact description;
  • dashboard links;
  • first checks;
  • rollback/mitigation steps;
  • escalation owner;
  • replay/reconciliation instructions where applicable.

Dashboard definition checklist и обязательные domain dashboards: Operational Dashboard Catalog.

Обратные ссылки

Автоссылки: где используется этот документ.