-
Notifications
You must be signed in to change notification settings - Fork 22
Draft Pull Request: Feature/Container Metrics #29
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: master
Are you sure you want to change the base?
Conversation
ffc0e2e to
614d8ea
Compare
…s; last accessed time check
614d8ea to
88408a2
Compare
Client logicInitiate metrics polling on stats tab clicking. 4588 if (key == 'Stats') {
4589 cmds._init_metrics_polling();
4590 }Handle metrics response 5093 if ('Metrics' in notification.Content) {If metrics received but we didn't receive stats inspector yet, wait // container.inspect.stats returned after container.metrics
if (state.inspector.content.length == 0) {
state.isLoading = false;
// to make first request as soon as posible
cmds._cancel_metrics_polling();
cmds._init_metrics_polling();
// do not process if no container.inspector.stats loaded
break;
}After metrics handled as usual and stored inside of inspector. Whenever users clicks on Stats, client receives fully accumulated metrics from the begining.
Todo
|
|
Hey Will!👋 I just wanted to remind about this pr and also summarise stuff which has been done. Client-side logic
Backend implementationArchitectureI introduced a new component:
Each container’s metrics are stored in a bounded ring buffer (size = 3000), overwriting old data automatically to prevent leaks or unbounded memory usage. Concurrency and safetyAll state-modifying operations in Polling workflow
Data structuretype MetricPoint struct {
CpuMetric float64 `json:"cpu"`
MemMetric float64 `json:"mem"`
Timestamp int64 `json:"timestamp"`
}These are stored per container in a bounded buffer: ringbuf.NewRingBuffer Server command additionAdded new case to the command handler: case "container.metrics":It handles request parsing, container state checking, poller initialization, and sending a notification with: Errors or inactive containers return an empty metrics array and TestingI’ve tested with:
Todo / Open questions
Would be great if you could take a look and maybe test it a bit — I’d really appreciate your feedback. Thanks! |
This pull request introduces the initial backend implementation for real-time container metrics, as discussed in issue #26. This is a draft PR to showcase the progress and discuss the current implementation before proceeding with the frontend and further backend refinements.
What's Done:
Discuss
Client disconnect context canceling
On client disconnect, I have implemented context canceling for Master node, but we might have some issues if for example first client started metrics polling, then second client tries to access that containers plot and then goes to the other container to check, metris will not be accumulated for that client if first client stop and will start only when second client try to access. Maybe because of this issue, we might need prefer to not stop polling after client disconnect.
I'm looking forward to your feedback on the current implementation.