> ## Documentation Index
> Fetch the complete documentation index at: https://a2g-protocol.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Observability & Audit

> Logging, metrics, traceability, and audit patterns.

## Logging

Servers SHOULD log the following for operational visibility:

* All `authenticate` and `authenticated` events (with wallet address, session ID)
* All `error` and `game_error` messages sent
* Session lifecycle events (connect, disconnect, reconnect, session\_expiring)
* Timeout events (which client, which table, what default action was applied)
* Account linkage changes (link, unlink, permission modifications)

Servers MUST NOT log authentication tokens or wallet private keys.

## Metrics

Key metrics to track:

| Metric                              | Why                 |
| ----------------------------------- | ------------------- |
| Active sessions                     | Capacity planning   |
| Authentication success/failure rate | Security monitoring |
| Average action response time        | Agent performance   |
| Timeout rate per game type          | Game UX health      |
| Reconnection rate                   | Network reliability |
| Error rate by code                  | System health       |

## Traceability

The `messageId` field on every message provides end-to-end traceability. Link game actions to their outcomes via `messageId` → `relatedMessageId` chains in error messages and round results.

## Audit Trail

For regulatory compliance, maintain an audit trail that includes:

* Complete game histories (all messages per round)
* Fund movements (deposits, withdrawals, game wins/losses, rake)
* Session lifecycle (connect, authenticate, disconnect, timeout)
* Account linkage events (link, unlink, permission changes)

The transaction history endpoint (`GET /api/wallet/transactions`) provides the financial audit trail. Supplement this with game-level event logging for complete coverage.
