Skip to content

Commit 6d7683d

Browse files
dahliaclaude
andcommitted
Persist log records in KvStore for cross-process access
Replace the in-memory Map-based LogStore with a KvStore-backed implementation so that logs produced by worker processes are visible in the debug dashboard served by the web process. LogStore.add() enqueues writes to a promise chain and exposes a flush() method; route handlers call flush() before reading to ensure all pending writes are visible. This avoids fromAsyncSink() which was incompatible with configureSync(). The advanced overload now requires a kv option alongside the exporter. The simplified overload shares the auto-created MemoryKvStore. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3147754 commit 6d7683d

3 files changed

Lines changed: 191 additions & 130 deletions

File tree

docs/manual/debug.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,18 @@ When provided, you are responsible for setting up the `BasicTracerProvider`
259259
and passing it to `createFederation()`. See the
260260
[Advanced setup](#advanced-setup) section below.
261261

262+
### `kv`
263+
264+
*Required when `exporter` is provided.* A `KvStore` instance used to persist
265+
log records collected by the debug dashboard's LogTape sink.
266+
267+
When using the simplified overload (without `exporter`), the debugger
268+
automatically creates a `MemoryKvStore` for log storage.
269+
270+
When using the advanced overload (with `exporter`), you must pass the same
271+
`KvStore` instance so that log records written by worker processes are visible
272+
in the web dashboard.
273+
262274

263275
Dashboard pages
264276
---------------
@@ -400,6 +412,7 @@ const innerFederation = createFederation({
400412
// Wrap the federation with the debugger:
401413
const federation = createFederationDebugger(innerFederation, {
402414
exporter,
415+
kv,
403416
});
404417
~~~~
405418

@@ -431,5 +444,5 @@ In this mode, you are responsible for:
431444
- Registering a `W3CTraceContextPropagator` as the global propagator
432445
- Creating and configuring the `BasicTracerProvider`
433446
- Passing `tracerProvider` to `createFederation()`
434-
- Passing the same `exporter` to `createFederationDebugger()`
447+
- Passing the same `exporter` and `kv` to `createFederationDebugger()`
435448
- Configuring LogTape with `federation.sink` to collect logs per trace

0 commit comments

Comments
 (0)