From 39830a410ad209c42203ee891be164e6e004c439 Mon Sep 17 00:00:00 2001 From: darkskygit Date: Tue, 3 Jun 2025 03:37:02 +0000 Subject: [PATCH] feat(server): add metrics for copilot job event (#12575) ## Summary by CodeRabbit - **Chores** - Improved internal monitoring for AI embedding operations to enhance reliability and performance tracking. No changes to user-facing features. --- packages/backend/server/src/plugins/copilot/context/job.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend/server/src/plugins/copilot/context/job.ts b/packages/backend/server/src/plugins/copilot/context/job.ts index 290ade53f..cef903ba7 100644 --- a/packages/backend/server/src/plugins/copilot/context/job.ts +++ b/packages/backend/server/src/plugins/copilot/context/job.ts @@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common'; import { AFFiNELogger, BlobNotFound, + CallMetric, Config, CopilotContextFileNotSupported, DocNotFound, @@ -65,6 +66,7 @@ export class CopilotContextDocJob { return this.client as EmbeddingClient; } + @CallMetric('ai', 'addFileEmbeddingQueue') async addFileEmbeddingQueue(file: Jobs['copilot.embedding.files']) { if (!this.supportEmbedding) return; @@ -184,7 +186,7 @@ export class CopilotContextDocJob { ); } - async readCopilotBlob( + private async readCopilotBlob( userId: string, workspaceId: string, blobId: string, @@ -375,6 +377,9 @@ export class CopilotContextDocJob { error instanceof CopilotContextFileNotSupported && error.message.includes('no content found') ) { + this.logger.warn( + `Doc ${docId} in workspace ${workspaceId} has no content, fulfilling empty embedding.` + ); // if the doc is empty, we still need to fulfill the embedding await this.fulfillEmptyEmbedding(workspaceId, docId); return;