Skip to content

Commit 8c23651

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
AI: add network initiator to trace events sent to LLM
Also a drive by to improve the priority; if they are both the same there is no need to output both the initial and final priority, so now we only do that if the priority changed. Fixed: 401195804 Change-Id: I8befa8190b32f9b5fa8e1562fbff4e74b6a542c8 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6333532 Auto-Submit: Jack Franklin <[email protected]> Commit-Queue: Nancy Li <[email protected]> Reviewed-by: Nancy Li <[email protected]>
1 parent 8ae7979 commit 8c23651

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

front_end/panels/ai_assistance/data_formatters/PerformanceInsightFormatter.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,11 @@ Timings:
127127
Durations:
128128
- Main thread processing duration: 3.51 ms
129129
- Total duration: 13.93 ms
130+
Initiator: https://chromedevtools.github.io/performance-stories/lcp-large-image/index.html
130131
Status code: 200
131132
MIME Type: text/css
132-
Priority:
133-
- Initial: VeryHigh
134-
- Final: VeryHigh
135-
Render blocking?: Yes
133+
Priority: VeryHigh
134+
Render blocking: Yes
136135
From a service worker: No
137136
Response headers
138137
- date: Thu, 07 Mar 2024 21:17:02 GMT

front_end/panels/ai_assistance/data_formatters/PerformanceInsightFormatter.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ export class TraceEventFormatter {
230230

231231
const renderBlocking = Trace.Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(request);
232232

233+
const initiator = parsedTrace.NetworkRequests.eventToInitiator.get(request);
234+
235+
const priorityLines = [];
236+
if (initialPriority === priority) {
237+
priorityLines.push(`Priority: ${priority}`);
238+
} else {
239+
priorityLines.push(`Initial priority: ${initialPriority}`);
240+
priorityLines.push(`Final priority: ${priority}`);
241+
}
242+
233243
if (!options.verbose) {
234244
return `## Network request: ${url}
235245
- Start time: ${formatMicro(startTimesForLifecycle.start)}
@@ -246,13 +256,11 @@ Timings:
246256
- Completed at: ${formatMicro(startTimesForLifecycle.processingComplete)}
247257
Durations:
248258
- Main thread processing duration: ${formatMicro(mainThreadProcessingDuration)}
249-
- Total duration: ${formatMicro(request.dur)}
259+
- Total duration: ${formatMicro(request.dur)}${initiator ? `\nInitiator: ${initiator.args.data.url}` : ''}
250260
Status code: ${statusCode}
251261
MIME Type: ${mimeType}
252-
Priority:
253-
- Initial: ${initialPriority}
254-
- Final: ${priority}
255-
Render blocking?: ${renderBlocking ? 'Yes' : 'No'}
262+
${priorityLines.join('\n')}
263+
Render blocking: ${renderBlocking ? 'Yes' : 'No'}
256264
From a service worker: ${fromServiceWorker ? 'Yes' : 'No'}
257265
${NetworkRequestFormatter.formatHeaders('Response headers', responseHeaders, true)}`;
258266
}

0 commit comments

Comments
 (0)