You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: backend/README.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,3 +84,10 @@ All REST API endpoints are prefixed with `/v1`. Refer to the API Documentation i
84
84
## Server-Sent Events (SSE)
85
85
86
86
The backend exposes an SSE endpoint (`/v1/streams/events`) to stream real-time updates to the frontend whenever on-chain stream events are indexed.
87
+
88
+
## Logging & Correlation IDs
89
+
90
+
Structured JSON logs generated by Winston (`backend/src/logger.ts`) attach a `requestId` correlation ID via `AsyncLocalStorage` (`requestContext`):
91
+
-**HTTP Requests:** Set via `requestIdMiddleware` (`X-Request-ID` header or auto-generated UUID).
92
+
-**Worker Poll Batches:** Each poll cycle in `SorobanEventWorker` runs in `requestContext.run({ requestId: randomUUID() }, ...)` so all event logs and error traces share a single ID per cycle.
93
+
-**Admin Replays:** Replays triggered via `replayFromLedger` / `POST /v1/admin/indexer/replay` execute under a shared `requestId` that is included in all indexer log statements and returned in the HTTP 202 JSON response.
Copy file name to clipboardExpand all lines: docs/ARCHITECTURE.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,8 +165,18 @@ Benefits:
165
165
## Operational Notes
166
166
167
167
1.`/v1/events/stats` exposes active SSE connections and connection-capacity metrics.
168
-
1. Admin metrics include SSE peak-per-IP visibility for abuse monitoring.
169
-
1. User summary endpoint (`/v1/users/{address}/summary`) is cached for 30s to protect DB hot paths.
168
+
2. Admin metrics include SSE peak-per-IP visibility for abuse monitoring.
169
+
3. User summary endpoint (`/v1/users/{address}/summary`) is cached for 30s to protect DB hot paths.
170
+
171
+
---
172
+
173
+
## Logging & Observability
174
+
175
+
All backend log lines use standard JSON formatting via Winston and include a `requestId` correlation ID field when running inside a request or worker context (managed by Node's `AsyncLocalStorage` via `requestContext` in `backend/src/logger.ts`).
176
+
177
+
-**HTTP Requests:** Requests receive or generate a `requestId` via `requestIdMiddleware` (`X-Request-ID` header).
178
+
-**Background Indexer/Worker Poll Cycles:** Each `SorobanEventWorker` poll batch runs inside `requestContext.run({ requestId: randomUUID() }, ...)` so all RPC fetches, event processing, and per-event error logs within that poll cycle share a single correlation ID.
179
+
-**Admin Replays:** Triggering an indexer event replay (via `replayFromLedger` or `POST /v1/admin/indexer/replay`) wraps the reset and worker poll cycle in `requestContext`. The correlation ID is included on all log statements emitted during replay and returned in the HTTP API response (`{ ok: true, replayingFrom: <ledger>, requestId: "<id>" }`).
0 commit comments