feat(server): add metrics for copilot job event (#12575)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Chores**
	- Improved internal monitoring for AI embedding operations to enhance reliability and performance tracking. No changes to user-facing features.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
darkskygit
2025-06-03 03:37:02 +00:00
parent ef3be4a816
commit 39830a410a

View File

@@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common';
import { import {
AFFiNELogger, AFFiNELogger,
BlobNotFound, BlobNotFound,
CallMetric,
Config, Config,
CopilotContextFileNotSupported, CopilotContextFileNotSupported,
DocNotFound, DocNotFound,
@@ -65,6 +66,7 @@ export class CopilotContextDocJob {
return this.client as EmbeddingClient; return this.client as EmbeddingClient;
} }
@CallMetric('ai', 'addFileEmbeddingQueue')
async addFileEmbeddingQueue(file: Jobs['copilot.embedding.files']) { async addFileEmbeddingQueue(file: Jobs['copilot.embedding.files']) {
if (!this.supportEmbedding) return; if (!this.supportEmbedding) return;
@@ -184,7 +186,7 @@ export class CopilotContextDocJob {
); );
} }
async readCopilotBlob( private async readCopilotBlob(
userId: string, userId: string,
workspaceId: string, workspaceId: string,
blobId: string, blobId: string,
@@ -375,6 +377,9 @@ export class CopilotContextDocJob {
error instanceof CopilotContextFileNotSupported && error instanceof CopilotContextFileNotSupported &&
error.message.includes('no content found') 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 // if the doc is empty, we still need to fulfill the embedding
await this.fulfillEmptyEmbedding(workspaceId, docId); await this.fulfillEmptyEmbedding(workspaceId, docId);
return; return;