arl / statsviz

🚀 Visualise your Go program runtime metrics in real time in the browser
MIT License
3.18k stars 121 forks source link

[Question] Custom metrics implementation questions #82

Closed kcyx closed 10 months ago

kcyx commented 1 year ago

Custom metrics is now easier after new released #75. But it seems that custom metrics like cpu, memory, io and network etc. must be implemented only inside statsviz's plot package which would be too invasive for the lib itself. Maybe we can change statsviz's interface for add-on metrics using http package's middleware pattern?

arl commented 1 year ago

That is what is planned. Now that metrics are dynamically plotted, some new API will allow users to add their own metrics, using a public API that has not yet been designed, which is based on internal/plot.

Maybe we can change statsviz's interface for add-on metrics using http package's middleware pattern?

That's seems complicated. In any case, I might create a new major version, v1, and break (slightly) compatibility, in order to propose a much simpler statsviz public API

kcyx commented 1 year ago

I see your point. Maybe it don't need too complicated mechanism for a public API to custom metrics. It can be done by implementing new exported method to add new metrics to internal plot slice as well as some boilerplate helper constructor for plotting style? Dose some PR needed for this?

arl commented 1 year ago

It can be done by implementing new exported method to add new metrics to internal plot slice as well as some boilerplate helper constructor for plotting style?

Yes, exactly. I was thinking to something along those lines. We need to see how that new API will interact with the handlers registering function Register.

Dose some PR needed for this?

I'm open to a PR on this. However since these are big changes, I think we should discuss them together, at least the high level design and public api. We can do so here on this issue or on slack/email.

kcyx commented 1 year ago

I think it would more convenient to move plot configuration out of default register procedure, and use the plot config to import custom plot series and styles, Then we can just change some method and parameters instead of introducing much stuff. On the other hand, set up the whole plot view before starting http server would be rather natural than using sync once method. BTW, is there any slack channel for it? It is quite common to use slack for discussion.

arl commented 1 year ago

I'm not really fond of the current public API using global state. Statsviz has grown out of its initial scope for which the global state API was ok. However if I'm going to cut a new API involving breaking change, I want to cut a v1 and get it right so as to not have to change it again anytime soon.

I've created the #statsviz channel on Gopher's slack. I'm on holiday at the moment, I'll look into that as soon as I can.

arl commented 10 months ago

@kcyx since v0.6.0 (released yesterday) users can now add their own plots to the dashboard.

I'm going to close this issue