fix: report visible loading spans in web probe (#656)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -7816,6 +7816,10 @@ function renderWebObserveAnalyzeTable(value: Record<string, unknown>): string {
|
||||
const runtimeAlerts = record(analysis?.runtimeAlerts);
|
||||
const pagePerformance = record(analysis?.pagePerformance);
|
||||
const promptNetwork = record(analysis?.promptNetwork);
|
||||
const loading = record(sampleMetrics?.loading);
|
||||
const loadingSummary = record(loading?.summary);
|
||||
const loadingSegments = Array.isArray(loading?.longestSegments) ? loading.longestSegments.map(record).filter((item): item is Record<string, unknown> => item !== null).slice(0, 8) : [];
|
||||
const loadingOwners = Array.isArray(loading?.owners) ? loading.owners.map(record).filter((item): item is Record<string, unknown> => item !== null).slice(0, 8) : [];
|
||||
const rounds = webObserveArray(sampleMetrics?.roundItems ?? sampleMetrics?.rounds).map(record).filter((item): item is Record<string, unknown> => item !== null).slice(-8);
|
||||
const turnColumns = webObserveArray(sampleMetrics?.turnColumns).map(record).filter((item): item is Record<string, unknown> => item !== null).slice(-12);
|
||||
const roundCount = Array.isArray(sampleMetrics?.rounds) ? sampleMetrics.rounds.length : sampleMetrics?.rounds;
|
||||
@@ -7995,15 +7999,49 @@ function renderWebObserveAnalyzeTable(value: Record<string, unknown>): string {
|
||||
]]),
|
||||
"",
|
||||
"Rounds:",
|
||||
webObserveTable(["ROUND", "SAMPLES", "TOTAL_LAST", "RECENT_LAST", "DIAG", "TERMINAL", "PROMPT_HASH"], rounds.length > 0 ? rounds.map((item) => [
|
||||
webObserveTable(["ROUND", "SAMPLES", "LOADING", "MAX_LOAD", "TOTAL_LAST", "RECENT_LAST", "DIAG", "TERMINAL", "PROMPT_HASH"], rounds.length > 0 ? rounds.map((item) => [
|
||||
webObserveText(item.promptIndex),
|
||||
webObserveText(item.sampleCount),
|
||||
webObserveText(item.loadingSamples),
|
||||
webObserveText(item.maxLoadingCount),
|
||||
webObserveText(item.lastTotalElapsedSeconds),
|
||||
webObserveText(item.lastRecentUpdateSeconds),
|
||||
webObserveText(item.diagnosticSamples),
|
||||
webObserveText(item.terminalSamples),
|
||||
webObserveShort(webObserveText(item.promptTextHash), 24),
|
||||
]) : [["-", "-", "-", "-", "-", "-", "-"]]),
|
||||
]) : [["-", "-", "-", "-", "-", "-", "-", "-", "-"]]),
|
||||
"",
|
||||
"Loading visibility:",
|
||||
webObserveTable(["SAMPLES", "LOADING_SAMPLES", "MAX_COUNT", "MAX_OWNERS", "OWNERS", "LONGEST_S", "CURRENT_S", "OVER5S"], [[
|
||||
webObserveText(loadingSummary?.sampleCount ?? sampleMetrics?.sampleCount),
|
||||
webObserveText(loadingSummary?.loadingSampleCount ?? sampleMetrics?.loadingSampleCount),
|
||||
webObserveText(loadingSummary?.maxSimultaneousCount ?? sampleMetrics?.loadingMaxCount),
|
||||
webObserveText(loadingSummary?.maxSimultaneousOwnerCount ?? sampleMetrics?.loadingMaxOwnerCount),
|
||||
webObserveText(loadingSummary?.ownerCount ?? sampleMetrics?.loadingOwnerCount),
|
||||
webObserveText(loadingSummary?.longestContinuousSeconds ?? sampleMetrics?.loadingLongestContinuousSeconds),
|
||||
webObserveText(loadingSummary?.currentContinuousSeconds ?? sampleMetrics?.loadingCurrentContinuousSeconds),
|
||||
webObserveText(loadingSummary?.overFiveSecondSegmentCount ?? sampleMetrics?.loadingOverFiveSecondSegmentCount),
|
||||
]]),
|
||||
"",
|
||||
"Loading owners:",
|
||||
webObserveTable(["SAMPLES", "OCCUR", "MAX", "LONGEST_S", "KIND", "OWNER"], loadingOwners.length > 0 ? loadingOwners.map((item) => [
|
||||
webObserveText(item.sampleCount),
|
||||
webObserveText(item.occurrenceCount),
|
||||
webObserveText(item.maxSimultaneousCount),
|
||||
webObserveText(item.longestContinuousSeconds),
|
||||
webObserveShort(webObserveText(item.ownerKind), 16),
|
||||
webObserveShort(webObserveText(item.ownerLabel ?? item.ownerKey), 64),
|
||||
]) : [["-", "-", "-", "-", "-", "-"]]),
|
||||
"",
|
||||
"Loading segments:",
|
||||
webObserveTable(["DURATION_S", "MAX", "OWNERS", "SEQ", "LAST", "STATUS"], loadingSegments.length > 0 ? loadingSegments.map((item) => [
|
||||
webObserveText(item.durationSeconds),
|
||||
webObserveText(item.maxCount),
|
||||
webObserveText(item.ownerCount),
|
||||
`${webObserveText(item.firstSeq)}..${webObserveText(item.lastSeq)}`,
|
||||
webObserveShort(webObserveText(item.lastAt), 24),
|
||||
item.ongoing === true ? "ongoing" : webObserveShort(webObserveText(item.endedAt), 24),
|
||||
]) : [["-", "-", "-", "-", "-", "-"]]),
|
||||
"",
|
||||
"Turn columns:",
|
||||
webObserveTable(["TURN", "PROMPT", "TRACE", "FIRST_SEQ", "LAST_SEQ", "SOURCE"], turnColumns.length > 0 ? turnColumns.map((item) => [
|
||||
@@ -8726,7 +8764,7 @@ const compactHeartbeat=(item)=>item?{ok:item.ok,jobId:item.jobId,pid:item.pid,st
|
||||
const retryLabel=(detail)=>detail&&detail.auth?detail.auth.lastRetryLabel||'':detail&&detail.result?detail.result.lastRetryLabel||'':detail&&detail.error&&detail.error.auth?detail.error.auth.lastRetryLabel||'':'';
|
||||
const detailText=(detail)=>detail&&detail.error?short((detail.error.message||'')+(detail.error.auth&&detail.error.auth.lastError?' '+detail.error.auth.lastError:'')):detail&&detail.result?short([detail.result.statusText,detail.result.retryExhausted?'retry-exhausted':''].filter(Boolean).join(' ')):'';
|
||||
const compactControl=(item)=>({ts:item.ts,seq:item.seq,phase:item.phase,type:item.type,commandId:item.commandId,durationMs:item.detail&&item.detail.durationMs||null,retry:retryLabel(item.detail),detail:detailText(item.detail)});
|
||||
const compactSample=(item)=>({seq:item.seq,ts:item.ts,path:item.path,routeSessionId:item.routeSessionId||null,activeSessionId:item.activeSessionId||null,messageCount:Array.isArray(item.messages)?item.messages.length:0,traceRowCount:Array.isArray(item.traceRows)?item.traceRows.length:0});
|
||||
const compactSample=(item)=>({seq:item.seq,ts:item.ts,path:item.path,routeSessionId:item.routeSessionId||null,activeSessionId:item.activeSessionId||null,messageCount:Array.isArray(item.messages)?item.messages.length:0,traceRowCount:Array.isArray(item.traceRows)?item.traceRows.length:0,loadingCount:Array.isArray(item.loadings)?item.loadings.length:0,loadingOwners:Array.isArray(item.loadings)?Array.from(new Set(item.loadings.map((loading)=>loading.ownerLabel||loading.ownerKind||loading.ownerKey||'loading'))).slice(0,4):[]});
|
||||
const compactNetwork=(item)=>({ts:item.ts,type:item.type,method:item.method,url:short(item.url),status:item.status||null,failure:item.failure?short(item.failure):null});
|
||||
const pidText=fs.existsSync(path.join(dir,'pid'))?fs.readFileSync(path.join(dir,'pid'),'utf8').trim():null;
|
||||
let alive=false; if(pidText){try{process.kill(Number(pidText),0); alive=true}catch{}}
|
||||
|
||||
Reference in New Issue
Block a user