-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Refactor the Output
interface
#2430
Comments
Without looking into the proposition too much: Given that #1831 will likely have breaking changes for outputs as well I would prefer if we don't break the interface once to then break it again. Especially as (from a quick look at this) one of the breaking changes will not beneficial to current outputs all that much, even if it keeps supporting them for some time. Given that I would prefer if we don't work on this before we work on #1831 which likely will need changes to the output interface as well. |
🤔 Good points 👍 Though I am not sure if we'll be able to gracefully deprecate the current outputs without a ton of effort for #1831, so maybe don't bother with that and do both breaking changes at once, to rip the band-aid off quickly? 😅 |
We should probably also add a context to either the current type Output interface {
// The output stops when `samples` is closed, and k6 will wait() for it to finish.
Start(samples chan stats.SampleContainer) (wait func(context.Context) error, err error)
} This will allow us to set a soft limit for how long outputs are allowed to stop. |
In the course of removing the The big problem there is that My current thinking is that since these run statuses are pretty much specific for our cloud API, so they should be moved to the Lines 78 to 82 in 5fa71b7
The logical solution would be to have some way to notify the output that the test has finished executing with some error. If the I'm in the process of making a PR with this refactoring, but I am also commenting in this issue because this will affect how we refactor the |
In that case, it could be something like: In the case of
For example, it would be beneficial for the Prometheus Remote Write Output that makes an HTTP call during the Stop operation. grafana/xk6-output-prometheus-remote#73 (comment) |
I've recently been going back to basics and making some substantial changes and refactors in how base components of k6 work. One of these has been the current
core.Engine
. Through #1889, #2426 and another WIP PR I've been slowly trying to split it apart and obviate it, since that will unlock a lot of flexibility and remove tons of cruft.During that effort, I've noticed another suboptimal component we have in k6, our outputs. This is the current
output.Output
API:k6/output/types.go
Lines 58 to 76 in 55c7ccd
And even though I was the one who kind of wrote it, I still think it's quite bad 😅 I think the biggest reason it's so bad is because it kind of had to be, due to the dysfunctional nature of our current Rube-Goldberg
core.Engine
😅 But I'm really close to getting rid of the Engine completely, and it has been making obvious how bad the Outputs are because of it...Here's what I actually propose the new Output API should look like:
Besides the fact that then new API is much simpler and more idiomatic Go code, the old API actually has a problem for the use case of k6. Specifically, buffering is important when we have network IO, but counter-productive when we're passing metrics internally in k6. It's probably somewhat jittery to have these buffers from
AddMetricSamples()
internally, since their batched processing will cause memory churn, but also small CPU usage spikes at intermittent intervals when they are processed. If there are CPU bursts every 50ms, that might affect the actual test execution and metric measurements... 😞I also think there is a way to do this transition gracefully and support both old and new Output extensions for a few releases (the old ones with an adapter to the new API that emits a warning). We can move the outputs to the new
/metrics/
top-level package and make the current/output
package a adapter proxy for the new API for a few k6 version. That proxy can emit a deprecation warning, so users can switch their extensions to the new API.The text was updated successfully, but these errors were encountered: