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

Make livereloading of watched dashboards more reliable #514

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

K-Phoen
Copy link
Member

@K-Phoen K-Phoen commented Oct 30, 2024

Instead of using Grafana's websocket to trigger a dashboard refresh, let's use a more crude approach and refresh the entire page.

The server-side implementation of the livereload process is taken from https://github.com/gohugoio/hugo/tree/62567d38205a61134a6822d37a534520772419f1/livereload

It has been adjusted to ensure that only dashboards that changed will be reloaded.

@K-Phoen K-Phoen self-assigned this Oct 30, 2024
@K-Phoen K-Phoen requested a review from a team as a code owner October 30, 2024 02:24
@@ -289,7 +289,7 @@ func (s *Server) updateWatchedResource(name string) error {
}
resources, err = s.ParseBytes(b)
} else {
resources, err = s.ParseResources(s.ResourcePath)
resources, err = s.ParseResources(name)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a drive-by fix: let's parse the resource that changed instead of re-parsing all of them.

Copy link
Member

@Duologic Duologic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

internal/livereload/connection.go Show resolved Hide resolved
Instead of using Grafana's websocket to trigger a dashboard refresh,
let's use a more crude approach and refresh the entire page.

The server-side implementation of the livereload process is
taken from https://github.com/gohugoio/hugo/tree/62567d38205a61134a6822d37a534520772419f1/livereload

It has been adjusted to ensure that only dashboards that changed will be
reloaded.
@K-Phoen K-Phoen force-pushed the more-reliable-livereload branch from d9d52ad to cb4eceb Compare October 30, 2024 15:51
@K-Phoen K-Phoen merged commit 32991db into main Oct 30, 2024
7 checks passed
@K-Phoen K-Phoen deleted the more-reliable-livereload branch October 30, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants