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 <noreply@anthropic.com>
This commit is contained in:
parent
5aaa8600c5
commit
be477c73c6
|
|
@ -604,6 +604,7 @@ export class DingTalkRouterService implements OnModuleInit, OnModuleDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance.status !== 'running') {
|
if (instance.status !== 'running') {
|
||||||
|
this.logger.warn(`Instance ${instance.id} (${instance.name}) not running: status=${instance.status}`);
|
||||||
this.reply(msg, `小龙虾「${instance.name}」当前状态为 ${instance.status},暂时无法接收指令。`);
|
this.reply(msg, `小龙虾「${instance.name}」当前状态为 ${instance.status},暂时无法接收指令。`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -615,6 +616,7 @@ export class DingTalkRouterService implements OnModuleInit, OnModuleDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
const bridgeUrl = `http://${instance.serverHost}:${instance.hostPort}/task`;
|
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
|
// sessionWebhook TTL is ~90 minutes (per DingTalk docs), but delivering the actual LLM
|
||||||
// response synchronously makes the user wait with no feedback. Strategy:
|
// 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'
|
reply = typeof result.result === 'string'
|
||||||
? result.result
|
? result.result
|
||||||
: JSON.stringify(result.result, null, 2);
|
: JSON.stringify(result.result, null, 2);
|
||||||
|
this.logger.log(`Bridge OK for instance ${instance.id}, reply length=${reply.length}`);
|
||||||
} else {
|
} else {
|
||||||
reply = result.error ?? '智能体没有返回内容。';
|
reply = result.error ?? '智能体没有返回内容。';
|
||||||
|
this.logger.warn(`Bridge returned error for instance ${instance.id}: ${reply}`);
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
this.logger.error(`Bridge call failed for instance ${instance.id}:`, e.message);
|
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 },
|
{ 'x-acs-dingtalk-access-token': token },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
this.logger.log(`batchSend OK for staffId=${staffId} msgId=${msgId} chunks=${chunks.length}`);
|
||||||
})
|
})
|
||||||
.catch((e: Error) =>
|
.catch((e: Error) =>
|
||||||
this.logger.error(`batchSend failed for msgId=${msgId}:`, e.message),
|
this.logger.error(`batchSend failed for msgId=${msgId}:`, e.message),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue