Skip to content
TypeScript

perf(server): stop tracing each transcript file in usage scans (#31586)

Julius Marminge8ee2f35eeb2d
diff --git a/apps/server/src/usage/UsageService.ts b/apps/server/src/usage/UsageService.ts
index 7e2e8586ed9..8876f0af131 100644
--- a/apps/server/src/usage/UsageService.ts
+++ b/apps/server/src/usage/UsageService.ts
@@ -439,9 +439,10 @@ export const make = Effect.gen(function* () {
/**
* Reads run concurrently, and the caller stores updates in walk order rather
* than completion order: saved records of deleted transcripts aggregate in
- * cache order, where the first copy of a duplicate wins.
+ * cache order, where the first copy of a duplicate wins. Untraced: a scan
+ * reads thousands of files, so scanTranscriptDir records the counts instead.
*/
- const readFileRecords = Effect.fn("UsageService.readFileRecords")(function* (
+ const readFileRecords = Effect.fnUntraced(function* (
filePath: string,
size: number,
mtimeMs: number,
@@ -597,6 +598,10 @@ export const make = Effect.gen(function* () {
return { path, records, malformedRecords };
});
const unread = failedPaths + read.filter((file) => file.failed).length;
+ yield* Effect.annotateCurrentSpan({
+ "usage.files": files.length,
+ "usage.files_parsed": read.filter((file) => file.update !== undefined).length,
+ });
return {
provider,
dir,