fix(web-probe): capture web performance diagnostics payloads
This commit is contained in:
@@ -753,6 +753,12 @@ function compactPerformanceWindow(item){
|
||||
function compactPerfFinding(item){
|
||||
return {severity:item?.severity??item?.level??null,id:short(item?.id||item?.kind||item?.code||'',56),count:item?.count??item?.sampleCount??null,rootCause:item?.rootCause??item?.rootCauseStatus??null,summary:short(item?.summary||item?.message||'',110),valuesRedacted:true};
|
||||
}
|
||||
function compactWebPerformanceDiagnosticGroup(item){
|
||||
return {diagnosticCode:short(item?.diagnosticCode||'',64),reason:short(item?.reason||'',48),module:short(item?.module||'',48),eventType:short(item?.eventType||'',48),count:item?.count??null,eventCount:item?.eventCount??null,chunkCount:item?.chunkCount??null,droppedCount:item?.droppedCount??null,maxFlushDurationMs:item?.maxFlushDurationMs??null,maxItemsPerChunk:item?.maxItemsPerChunk??null,maxChunkMs:item?.maxChunkMs??null,replacedByKeyCount:item?.replacedByKeyCount??null,firstAt:item?.firstAt??null,lastAt:item?.lastAt??null,traceIds:Array.isArray(item?.traceIds)?item.traceIds.slice(0,2).map((id)=>short(id,32)):[],valuesRedacted:true};
|
||||
}
|
||||
function compactWebPerformancePayloadState(item){
|
||||
return {state:short(item?.state||'',48),count:item?.count??null,valuesRedacted:true};
|
||||
}
|
||||
function compactPerfCommand(row){
|
||||
return {bucket:row?.bucket||null,id:short(commandFileId(row)||'',40),type:short(commandFileType(row)||'',32),ts:short(commandFileTs(row)||'',32),ageSeconds:row?.data?.ageSeconds??null,relative:short(row?.relative||'',72),valuesRedacted:true};
|
||||
}
|
||||
@@ -830,6 +836,9 @@ function performanceWindowsForSummary(rows){
|
||||
function performanceSummaryFromReport(){
|
||||
const perf=report.frontendPerformance&&typeof report.frontendPerformance==='object'?report.frontendPerformance:{};
|
||||
const summary=perf.summary&&typeof perf.summary==='object'?perf.summary:{};
|
||||
const runtime=report.runtimeAlerts&&typeof report.runtimeAlerts==='object'?report.runtimeAlerts:{};
|
||||
const runtimeSummary=runtime.summary&&typeof runtime.summary==='object'?runtime.summary:{};
|
||||
const payloadStates=runtime.webPerformancePayloadStates&&typeof runtime.webPerformancePayloadStates==='object'?runtime.webPerformancePayloadStates:{};
|
||||
const findings=Array.isArray(report.findings)?report.findings.filter((item)=>String(item?.id||item?.kind||'').match(/^frontend-(?:long|event-loop|cpu-profile|performance)/u)).slice(0,6).map(compactPerfFinding):[];
|
||||
const captureRows=Array.isArray(perf.captures)?perf.captures:[];
|
||||
const commandFiles=readCommandFiles();
|
||||
@@ -843,6 +852,7 @@ function performanceSummaryFromReport(){
|
||||
profileStacks:Array.isArray(perf.profileStacks)?perf.profileStacks.slice(0,2).map(compactProfileStack):[],
|
||||
captures:captureRows.slice(-3).map(compactPerfCapture),
|
||||
sourceAttribution:perf.sourceAttribution&&typeof perf.sourceAttribution==='object'?{sourceMapStatus:perf.sourceAttribution.sourceMapStatus??null,note:short(perf.sourceAttribution.note||'',120),sourceFiles:Array.isArray(perf.sourceAttribution.sourceFiles)?perf.sourceAttribution.sourceFiles.slice(0,4):[],valuesRedacted:true}:null,
|
||||
webPerformanceRuntime:{summary:{payloadRequestCount:runtimeSummary.webPerformancePayloadRequestCount??0,payloadParsedCount:runtimeSummary.webPerformancePayloadParsedCount??0,payloadParseIssueCount:runtimeSummary.webPerformancePayloadParseIssueCount??0,runtimeDiagnosticCount:runtimeSummary.webPerformanceRuntimeDiagnosticCount??0,runtimeDiagnosticGroupCount:runtimeSummary.webPerformanceRuntimeDiagnosticGroupCount??0,capturedEventCount:payloadStates.capturedEventCount??0,storedEventCount:payloadStates.storedEventCount??0,valuesRedacted:true},states:Array.isArray(payloadStates.states)?payloadStates.states.slice(0,6).map(compactWebPerformancePayloadState):[],groups:Array.isArray(runtime.webPerformanceRuntimeDiagnosticsByCode)?runtime.webPerformanceRuntimeDiagnosticsByCode.slice(0,6).map(compactWebPerformanceDiagnosticGroup):[],valuesRedacted:true},
|
||||
findings,
|
||||
toolFindings:performanceToolFindings(),
|
||||
valuesRedacted:true
|
||||
@@ -881,6 +891,13 @@ function renderPerformanceSummary(perf){
|
||||
lines.push('','LoAF script hotspots');
|
||||
if(perf.scriptHotspots.length===0) lines.push('-');
|
||||
for(const item of perf.scriptHotspots.slice(0,4)) lines.push(String(item.totalDurationMs??0)+'ms total count='+String(item.count??0)+' '+short(item.sourceFunctionName||item.invoker||'(anonymous)',40)+' '+short(item.sourceFile||item.sourceURL||'-',70)+' sourceLine='+String(item.sourceLine??'-')+' rawLine='+String(item.lineNumber??'-')+' char='+String(item.sourceCharPosition??'-')+' sourceMap='+String(item.sourceMapStatus||'-'));
|
||||
const webPerf=perf.webPerformanceRuntime||{};
|
||||
const webPerfSummary=webPerf.summary||{};
|
||||
lines.push('','Web performance runtime diagnostics');
|
||||
lines.push('payloads='+String(webPerfSummary.payloadRequestCount??0)+' parsed='+String(webPerfSummary.payloadParsedCount??0)+' parseIssues='+String(webPerfSummary.payloadParseIssueCount??0)+' events='+String(webPerfSummary.runtimeDiagnosticCount??0)+' groups='+String(webPerfSummary.runtimeDiagnosticGroupCount??0));
|
||||
if(Array.isArray(webPerf.states)&&webPerf.states.length>0) lines.push(' payload states='+webPerf.states.map((item)=>String(item.state||'-')+':'+String(item.count??0)).join(', '));
|
||||
if(!Array.isArray(webPerf.groups)||webPerf.groups.length===0) lines.push('-');
|
||||
for(const item of (webPerf.groups||[]).slice(0,6)) lines.push(String(item.diagnosticCode||item.eventType||'-')+' reason='+String(item.reason||'-')+' module='+String(item.module||'-')+' count='+String(item.count??0)+' eventCount='+String(item.eventCount??'-')+' chunks='+String(item.chunkCount??'-')+' flushMax='+String(item.maxFlushDurationMs??'-')+'ms dropped='+String(item.droppedCount??'-')+' maxItemsPerChunk='+String(item.maxItemsPerChunk??'-')+' maxChunkMs='+String(item.maxChunkMs??'-')+' replacedByKey='+String(item.replacedByKeyCount??'-'));
|
||||
lines.push('','Time-window correlation');
|
||||
if(!Array.isArray(perf.performanceWindows)||perf.performanceWindows.length===0) lines.push('-');
|
||||
for(const item of (perf.performanceWindows||[]).slice(0,3)){
|
||||
|
||||
Reference in New Issue
Block a user