fix: 全链路追踪时间显示 — UTC→UTC+8 本地时间
- 新增 formatLocalTime() 替换 toISOString() - 追踪面板时间显示为北京时间 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+12
-4
@@ -1304,7 +1304,7 @@ app.get('/api/trace/recent', async (req, res) => {
|
||||
const groupName = entry.group_name ? ` (${entry.group_name})` : '';
|
||||
traces.push({
|
||||
id: `msg-${ts}-${Math.random().toString(36).slice(2, 6)}`,
|
||||
timestamp: new Date(ts).toISOString(), ts,
|
||||
timestamp: formatLocalTime(ts), ts,
|
||||
service: 'platform-bridge',
|
||||
hop,
|
||||
label: `${icon} ${isIncoming ? '收到' : '发送'}消息 · ${entry.platform || '?'}${groupName}`,
|
||||
@@ -1322,7 +1322,7 @@ app.get('/api/trace/recent', async (req, res) => {
|
||||
const ts = call.time ? new Date(call.time).getTime() : Date.now();
|
||||
traces.push({
|
||||
id: `llm-${ts}-${Math.random().toString(36).slice(2, 6)}`,
|
||||
timestamp: new Date(ts).toISOString(), ts,
|
||||
timestamp: formatLocalTime(ts), ts,
|
||||
service: 'ai-core', hop: 'llm_call',
|
||||
label: `🧠 LLM: ${call.model || 'unknown'}`,
|
||||
status: call.success ? 'success' : 'error',
|
||||
@@ -1355,7 +1355,7 @@ app.get('/api/trace/recent', async (req, res) => {
|
||||
const ts = ev.timestamp ? new Date(ev.timestamp).getTime() : Date.now();
|
||||
traces.push({
|
||||
id: ev.id || `trace-${ts}`,
|
||||
timestamp: new Date(ts).toISOString(), ts,
|
||||
timestamp: formatLocalTime(ts), ts,
|
||||
service: 'ai-core',
|
||||
hop: ev.hop || 'trace',
|
||||
label: ev.label || '',
|
||||
@@ -1373,7 +1373,7 @@ app.get('/api/trace/recent', async (req, res) => {
|
||||
const ts = s.last_activity ? new Date(s.last_activity).getTime() : Date.now();
|
||||
traces.push({
|
||||
id: `session-${s.session_id || ''}`,
|
||||
timestamp: new Date(ts).toISOString(), ts,
|
||||
timestamp: formatLocalTime(ts), ts,
|
||||
service: 'gateway', hop: 'session',
|
||||
label: `👤 会话: ${userID}`,
|
||||
status: s.state === 'streaming' ? 'running' : 'success',
|
||||
@@ -1907,6 +1907,14 @@ server.listen(ETHEND_PORT, () => {
|
||||
}
|
||||
});
|
||||
|
||||
// 时间格式化:UTC+8 本地时间
|
||||
function formatLocalTime(ts) {
|
||||
var d = new Date(ts);
|
||||
var pad = function(n) { return n < 10 ? '0' + n : '' + n; };
|
||||
return d.getFullYear() + '-' + pad(d.getMonth()+1) + '-' + pad(d.getDate()) + ' ' +
|
||||
pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds());
|
||||
}
|
||||
|
||||
// 优雅退出
|
||||
process.on('SIGINT', async () => {
|
||||
console.log('\n关闭所有服务...');
|
||||
|
||||
Reference in New Issue
Block a user