Skip to content

Commit

Permalink
refactor(canary): Move logger creation inside token measurement scope
Browse files Browse the repository at this point in the history
Delay logger instantiation until it's actually needed within the token
measurement context. This change prevents unnecessary logger creation when
token measurement might not occur.

Changes:
- Remove early logger creation at function start
- Move createLogger call inside withTokenMeasurement function
- Maintain same logging functionality with better scoping
  • Loading branch information
toyamarinyon committed Dec 13, 2024
1 parent 9bb455e commit 07ff199
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions app/(playground)/p/[agentId]/canary/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ export async function action(
if (node === undefined) {
throw new Error("Node not found");
}
const logger = createLogger(node.content.type);

/**
* This function is a helper that retrieves a node from the graph
* based on its NodeHandleId. It looks for a connection in the
Expand Down Expand Up @@ -343,7 +341,7 @@ export async function action(
const result = await object;

await withTokenMeasurement(
logger,
createLogger(node.content.type),
async () => {
generationTracer.end({ output: result });
await lf.shutdownAsync();
Expand Down

0 comments on commit 07ff199

Please sign in to comment.