-
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
Move Output options in lib.Options #587
Comments
Started on this last Friday, but then I realized there are some things we need to consider:
|
Another thing that we should consider. Generally in k6, options with more precedence will override options with less (defaults < config file < exported script options < environment variables < command-line flags). For example, if we have defined In the case of export let options = {
collectors: {
mydebug: {
type: "json",
dest: "test.json",
// ...
},
db1: {
type: "influxdb",
url: "https://localhost:8086",
tagsAsFields: ["vu", "iter"],
// ...
},
db2: {
type: "influxdb",
url: "http://someinfluxdbhost.lan:8086",
tagsAsFields: ["vu", "iter", "url"],
// ...
},
}.
}; I think that approach gives us the greatest amount of flexibility:
I'm not sure how easy it would be to specify collector IDs via the CLI flags, but we can probably allow users to elide IDs and reuse the type as an ID unless they they try to use the same collector type multiple times. |
@na-- I think your second proposal allowing the In terms of the naming, I usually refer to the "collectors" as "outputs" which I think is a bit easier to interpret than the former, so my vote would be on using "outputs" 😄...as you say it's also what we've used in the user-facing parts: the CLI ( |
Hmm good point, the json config is probably way less used than the CLI flags, so |
Something else occurred to me while dealing with other stuff, so note to future self: since this refactoring is going to involve obsoleting a lot of collector config avenues:
... and since we'd still need to support those config avenues for a couple of k6 versions (while emitting a warning), we need some way to detect if a user actually uses any of them. That could be troublesome since those configs are mostly just plain Go structs that we unmarshal stuff into and call their |
During a discussion with @Griatch I noticed that there are some issues with handling environment variables that current are supposed to overwrite some cloud config options, i.e. |
I have made a a very small PoC commit (after some particular problems) that makes this possible. And due to some other changes through out k6 over the years let a script user get output configuration which turns out to be a thing few users want. import execution from "k6/execution";
export default function() {
console.log(execution.test.options.cloud)
console.log(execution.test.options.outputs["cloud"])
} will output There is plethora of problems:
But this do work with |
cc @grafana/k6-browser I know that you are currently somewhat hackishly accessing test run id - does this also work for you? |
The configuration for different collectors is currently in the
Config
struct, which containslib.Options
. This allows collectors to be configured via environment variables or the global k6 config, but not by exporting the settings via theoptions
object from scripts. The only exception to this is configuring the cloud collector via thelib.Options.External
property (settingoptions['ext']['loadimpact']
in the script), which is suboptimal (configuring the same thing from 2 different places in 2 different ways, works for cloud collector but not influxdb or others in the future, etc.)Moving the collector options to
lib.Options
would alleviate all of those issues. Thelib.options.External
configuration would still remain, but it will be used for other loadimpact cloud specific settings.The text was updated successfully, but these errors were encountered: