feat(logging): enhance API request logging and implement noRetry flag for improved error handling and diagnostics
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m54s

This commit is contained in:
2026-02-24 13:39:59 +07:00
parent 6290a84cd3
commit 657c23d237
4 changed files with 27 additions and 6 deletions
+10
View File
@@ -0,0 +1,10 @@
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:request","message":"API request started","data":{"method":"GET","url":"/alerts"},"timestamp":1771915099232}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:response","message":"API response received","data":{"method":"GET","url":"/alerts","status":200},"timestamp":1771915099568}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:request","message":"API request started","data":{"method":"GET","url":"/alerts"},"timestamp":1771915128313}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:response","message":"API response received","data":{"method":"GET","url":"/alerts","status":200},"timestamp":1771915128707}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:request","message":"API request started","data":{"method":"GET","url":"/mikrotik/address-lists"},"timestamp":1771915153565}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:response","message":"API response received","data":{"method":"GET","url":"/mikrotik/address-lists","status":200},"timestamp":1771915154115}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:request","message":"API request started","data":{"method":"GET","url":"/alerts"},"timestamp":1771915159241}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:response","message":"API response received","data":{"method":"GET","url":"/alerts","status":200},"timestamp":1771915159566}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:request","message":"API request started","data":{"method":"GET","url":"/alerts"},"timestamp":1771915188306}
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:response","message":"API response received","data":{"method":"GET","url":"/alerts","status":200},"timestamp":1771915188980}
+5 -5
View File
@@ -436,16 +436,16 @@ function initNetworkMapScheduler(logger, port) {
const intervalMs = settings.intervalMinutes * 60 * 1000;
log.info(
{ component: 'network-map-scheduler', intervalMinutes: settings.intervalMinutes },
'Network map scheduler started (first run in 10 s, then every %d min)',
'Network map scheduler started (runs every %d min by interval only)',
settings.intervalMinutes
);
schedulerTimer = setInterval(() => tick('interval'), intervalMs);
// Первый запуск через 10 сек, чтобы кеш появился вскоре после старта сервера
sendDebugLog('backend/services/networkMapScheduler.js:schedule-startup-tick', 'Startup delayed tick scheduled', {
delayMs: 10000,
// #region agent log
sendDebugLog('backend/services/networkMapScheduler.js:schedule-startup-tick-skipped', 'Startup delayed tick skipped', {
reason: 'disabled_to_avoid_immediate_speedtest_after_restart',
intervalMs,
});
setTimeout(() => tick('startup-delay'), 10 * 1000);
// #endregion
}
schedule();
+4 -1
View File
@@ -151,7 +151,10 @@ export default function ResourceStatsPage() {
const fetchStats = useCallback(async (abortSignal) => {
setLoading(true);
setError(null);
const opts = { timeout: REQUEST_TIMEOUT_MS, ...(abortSignal ? { signal: abortSignal } : {}) };
const opts = { timeout: REQUEST_TIMEOUT_MS, noRetry: true, ...(abortSignal ? { signal: abortSignal } : {}) };
// #region agent log
fetch('http://127.0.0.1:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'resource-stats-fix',hypothesisId:'H_RS_RETRY',location:'frontend/src/ResourceStatsPage.jsx:fetchStats',message:'Resource stats request started with noRetry',data:{timeoutMs:REQUEST_TIMEOUT_MS,noRetry:true,hasAbortSignal:Boolean(abortSignal)},timestamp:Date.now()})}).catch(()=>{});
// #endregion
try {
const res = await api.get('/resources/stats', opts);
const data = res?.data;
+8
View File
@@ -74,6 +74,14 @@ api.interceptors.response.use(
const config = error?.config || {};
const method = String(config.method || 'get').toUpperCase();
const noRetry = config?.noRetry === true || config?.__noRetry === true;
if (noRetry) {
// #region agent log
fetch('http://127.0.0.1:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'resource-stats-fix',hypothesisId:'H_RS_RETRY',location:'frontend/src/lib/api.js:retry-disabled-by-config',message:'Skip retry due to noRetry flag',data:{method:String(method),url:String(config?.url||''),code:String(error?.code||''),retryCount:Number(config?.__retryCount||0)},timestamp:Date.now()})}).catch(()=>{});
// #endregion
return Promise.reject(error);
}
// Инициализируем счетчик попыток
config.__retryCount = config.__retryCount || 0;