From be477c73c6c0bede41998c0f2d9c0fa4b5a6cae1 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 9 Mar 2026 00:19:02 -0700 Subject: [PATCH] fix(dingtalk): add observability logging to routing success paths - Log when routing starts (instance found, bridge URL) - Log bridge OK with reply length - Log bridge error response - Log instance not-running status - Log batchSend OK with chunk count Co-Authored-By: Claude Sonnet 4.6 --- .../src/infrastructure/dingtalk/dingtalk-router.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/services/agent-service/src/infrastructure/dingtalk/dingtalk-router.service.ts b/packages/services/agent-service/src/infrastructure/dingtalk/dingtalk-router.service.ts index 9d8b26a..06ea1f1 100644 --- a/packages/services/agent-service/src/infrastructure/dingtalk/dingtalk-router.service.ts +++ b/packages/services/agent-service/src/infrastructure/dingtalk/dingtalk-router.service.ts @@ -604,6 +604,7 @@ export class DingTalkRouterService implements OnModuleInit, OnModuleDestroy { } if (instance.status !== 'running') { + this.logger.warn(`Instance ${instance.id} (${instance.name}) not running: status=${instance.status}`); this.reply(msg, `小龙虾「${instance.name}」当前状态为 ${instance.status},暂时无法接收指令。`); return; } @@ -615,6 +616,7 @@ export class DingTalkRouterService implements OnModuleInit, OnModuleDestroy { } const bridgeUrl = `http://${instance.serverHost}:${instance.hostPort}/task`; + this.logger.log(`Routing msgId=${msg.msgId} → instance ${instance.id} (${instance.name}) @ ${bridgeUrl}`); // sessionWebhook TTL is ~90 minutes (per DingTalk docs), but delivering the actual LLM // response synchronously makes the user wait with no feedback. Strategy: @@ -641,8 +643,10 @@ export class DingTalkRouterService implements OnModuleInit, OnModuleDestroy { reply = typeof result.result === 'string' ? result.result : JSON.stringify(result.result, null, 2); + this.logger.log(`Bridge OK for instance ${instance.id}, reply length=${reply.length}`); } else { reply = result.error ?? '智能体没有返回内容。'; + this.logger.warn(`Bridge returned error for instance ${instance.id}: ${reply}`); } } catch (e: any) { this.logger.error(`Bridge call failed for instance ${instance.id}:`, e.message); @@ -680,6 +684,7 @@ export class DingTalkRouterService implements OnModuleInit, OnModuleDestroy { { 'x-acs-dingtalk-access-token': token }, ); } + this.logger.log(`batchSend OK for staffId=${staffId} msgId=${msgId} chunks=${chunks.length}`); }) .catch((e: Error) => this.logger.error(`batchSend failed for msgId=${msgId}:`, e.message),