-
Couldn't load subscription status.
- Fork 55
Timing Metric Gathering #357
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
base: dev
Are you sure you want to change the base?
Conversation
|
Resolves #353 |
| @@ -0,0 +1,317 @@ | |||
| import log from 'electron-log' | |||
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.
Check if existing timing libraries offer the same feature + maybe 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.
and replace log.x with console.x
| /** | ||
| * Get current queue stats (for debugging) | ||
| */ | ||
| getStats() { |
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.
llm bad
| itoSessionManager: mockitoSessionManager, | ||
| })) | ||
|
|
||
| const mockTimingCollector = { |
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.
see if i can put it in the preload
|
account for pill kickoff |
| events: TimingEvent[] | ||
| total_duration_ms: number | ||
| } | ||
|
|
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.
check to see if theres dupe code here from client logs
| @@ -0,0 +1,138 @@ | |||
| import type { FastifyInstance } from 'fastify' | |||
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.
see if buf works 🔫
| const now = Date.now() | ||
| const entries = reports.map(report => { | ||
| const structured = { | ||
| '@timestamp': new Date().toISOString(), |
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.
just change this to the client timestamp
|
|
||
| this.activeTimings.set(interactionId, { | ||
| interaction_id: interactionId, | ||
| start_timestamp: new Date().toISOString(), |
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.
We should use perf_hooks.performance.now() instead of Date(), since Date() can be adjusted by the system clock. E.g. when daylight savings time hits, we may see anomalous 1 hr+ sessions if we use Date()
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.
One more note -- for the very first interaction, we should use Date().toISOString() as the start_timestamp, so that we know roughly when this happened in human time. But for any other timestamps, we should use performance.now()
|
|
||
| // Calculate total duration | ||
| const events = Array.from(active.events.values()) | ||
| const firstEvent = events.find(e => e.name === TimingEventName.HOTKEY_PRESS) |
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.
We should make this a class constant, and remember that a Pill click might be the actual first click
| const serverUrl = | ||
| import.meta.env.VITE_GRPC_BASE_URL || 'http://localhost:3001' | ||
| const payload = { reports: reportsToSend } | ||
|
|
||
| const token = (store.get(STORE_KEYS.ACCESS_TOKEN) as string | null) || '' | ||
| const response = await fetch(`${serverUrl}/timing`, { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| ...(token ? { Authorization: `Bearer ${token}` } : {}), | ||
| }, | ||
| body: JSON.stringify(payload), | ||
| }) |
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.
We should be able to move this call to the grpcClient
| log.error('[itoSessionManager] Failed to fetch/send context:', error) | ||
| }) | ||
|
|
||
| this.interactionId = interactionId |
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.
Do we need to set this? Can we just retrieve it when needed from the InteractionManager?
| public async initialize(mode: ItoMode): Promise<boolean> { | ||
| public async initialize( | ||
| mode: ItoMode, | ||
| interactionId: string, |
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.
I'm not a huge fan of sprinkling interactionId throughout the code. Can we try to keep it isolated to InteractionManager?
No description provided.