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

statsviz.TimeSeries.GetValue is called multiple times per second #119

Open
mzzsfy opened this issue Dec 21, 2023 · 3 comments
Open

statsviz.TimeSeries.GetValue is called multiple times per second #119

mzzsfy opened this issue Dec 21, 2023 · 3 comments

Comments

@mzzsfy
Copy link

mzzsfy commented Dec 21, 2023

Open 2 or more pages and you will see the phenomenon

code like this:

statsviz.NewServer(statsviz.TimeseriesPlot(func() statsviz.TimeSeriesPlot {
        plot, _ := statsviz.TimeSeriesPlotConfig{
            Name:  "testCall",
            Title: "testCall",
            Type:  statsviz.Scatter,
            Series: []statsviz.TimeSeries{{
                Name:     "call",
                GetValue: func() float64 {
                    println("call",time.Now().Format(time.DateTime))
                    return float64(0)
                },
            }},
        }.Build()
        return plot
    }()))

Here's the log with 3 pages opened
image

@arl
Copy link
Owner

arl commented Dec 21, 2023

Currently statsviz creates a new connection for each client/browser that connects to it.
For each connection there's a once per second timer that gets the stats.

The orignal use case wasn't to have more than one client.
Ok that's a bug.
Thanks for reporting!

@AlekSi
Copy link
Sponsor

AlekSi commented Dec 21, 2023

I was sure it was a feature and built our own locking around it 😆

@arl
Copy link
Owner

arl commented Dec 21, 2023

Bugs, features... That's just different point of views 😅😅

But yes I think that statsviz should be restructured so that there's a single timer for N client connections. Shouldn't be too hard

mzzsfy added a commit to mzzsfy/statsviz that referenced this issue Jan 4, 2024
mzzsfy added a commit to mzzsfy/statsviz that referenced this issue Jan 5, 2024
mzzsfy added a commit to mzzsfy/statsviz that referenced this issue Jan 6, 2024
mzzsfy added a commit to mzzsfy/statsviz that referenced this issue Jan 6, 2024
delete websocket
done arl#117
done arl#119
done arl#120
mzzsfy added a commit to mzzsfy/statsviz that referenced this issue Jan 20, 2024
@mzzsfy mzzsfy mentioned this issue Jan 20, 2024
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 a pull request may close this issue.

3 participants