Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding PerformanceObserver for long task and animation frame #6251

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions vscode/webviews/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,28 @@ export const App: React.FunctionComponent<{ vscodeAPI: VSCodeWrapper }> = ({ vsc
[vscodeAPI, telemetryRecorder, config]
)

useEffect(() => {
const observePerformance = (entryType: string, eventName: string) => {
const observer = new PerformanceObserver(list => {
for (const entry of list.getEntries()) {
telemetryRecorder.recordEvent(`cody.webview.${eventName}`, 'performance', {
metadata: { duration: entry.duration },
})
}
})
observer.observe({ entryTypes: [entryType] })
return observer
}

const longTaskObserver = observePerformance('longtask', 'longTask')
const loafObserver = observePerformance('frame', 'longAnimationFrame')

return () => {
longTaskObserver.disconnect()
loafObserver.disconnect()
}
}, [telemetryRecorder])

// Wait for all the data to be loaded before rendering Chat View
if (!view || !config) {
return <LoadingPage />
Expand Down
Loading