Skip to content

Commit 2b8185b

Browse files
committed
chore(rivetkit): log runner id with actor logs
1 parent 60e4821 commit 2b8185b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

rivetkit-typescript/packages/rivetkit/src/actor/driver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ export interface ActorDriver {
5050
// Serverless
5151
/** This handles the serverless start request. This should manage the lifecycle of the runner tied to the request lifecycle. */
5252
serverlessHandleStart?(c: HonoContext): Promise<Response>;
53+
54+
/** Extra properties to add to logs for each actor. */
55+
getExtraActorLogParams?(): Record<string, string>;
5356
}

rivetkit-typescript/packages/rivetkit/src/actor/instance.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
328328
actorId,
329329
};
330330

331+
const extraLogParams = actorDriver.getExtraActorLogParams?.();
332+
if (extraLogParams) Object.assign(logParams, extraLogParams);
333+
331334
this.#log = getBaseLogger().child(
332335
Object.assign(
333336
getIncludeTarget() ? { target: "actor" } : {},

rivetkit-typescript/packages/rivetkit/src/drivers/engine/actor-driver.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,4 +597,8 @@ export class EngineActorDriver implements ActorDriver {
597597
await this.#runnerStopped.promise;
598598
});
599599
}
600+
601+
getExtraActorLogParams(): Record<string, string> {
602+
return { runnerId: this.#runner.runnerId ?? "-" };
603+
}
600604
}

0 commit comments

Comments
 (0)