-
Notifications
You must be signed in to change notification settings - Fork 454
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
feat(studio): detect and report high listener roundtrip latency #8943
Conversation
2a882bb
to
d8338e8
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
No changes to documentation |
⚡️ Editor Performance ReportUpdated Mon, 17 Mar 2025 16:50:13 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
shard?: string | ||
} | ||
export const HighListenerLatencyOccurred = defineEvent<Samples>({ | ||
name: 'High Listener Latency Detected', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from rxjs perspective, but I have limited insight into general behavior in studio paths 🙂
@@ -155,6 +156,19 @@ export function useDocumentStore(): DocumentStore { | |||
[telemetry], | |||
) | |||
|
|||
const handleReportLatency = useCallback( | |||
(event: LatencyReportEvent) => { | |||
if (event.latencyMs > 1000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move into constant(Could belong with the telemetry event? 🤔) and maybe describe why and what this number is? As a reference and help for our future selves 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Extracted to a const in 5f918c7
packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks great! I was able to see the telemetry logs client-side as expected during my testing.
Description
We want to track e2e listener latency, this reports a telemetry event every time we detect >1s latency from after an edit action request has completed until we receive an event with a corresponding transaction id back from the listener.
What to review
I've tried to implement this as cleanly as possible to make it easy to delete the code path for tracking latency at some point in the future. The implementation follows the same pattern as the "document desynced" event in the document store takes a callback that will be called with latency, shard identifier and transaction id.
Testing
To see that the the Studio sends the event, start with
SANITY_STUDIO_DEBUG_TELEMETRY=true pnpm dev
which will log the telemetry events to the console.This, combined with network throttling should likely cause some "High Listener Latency Detected"-events to be reported
Notes for release
n/a