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

Soft interface #2

Merged
merged 10 commits into from
Mar 18, 2021
Merged

Soft interface #2

merged 10 commits into from
Mar 18, 2021

Conversation

mattdurham
Copy link

No description provided.

Signed-off-by: matt durham <mattdurham@ppog.org>
Signed-off-by: matt durham <mattdurham@ppog.org>
Signed-off-by: matt durham <mattdurham@ppog.org>
Signed-off-by: matt durham <mattdurham@ppog.org>
Signed-off-by: matt durham <mattdurham@ppog.org>
Signed-off-by: matt durham <mattdurham@ppog.org>
Signed-off-by: matt durham <mattdurham@ppog.org>
Signed-off-by: matt durham <mattdurham@ppog.org>
@@ -43,7 +38,7 @@ type prometheusVersion struct {
}

const (
defaultCollectors = "cpu,cs,logical_disk,net,os,service,system,textfile"
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to remove textfile here?

Copy link
Author

Choose a reason for hiding this comment

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

No! Removing

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

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

Early feedback, I have some concerns about the kingpin abstraction

t := time.Now()
cs := make([]string, 0, len(coll.collectors))
for name := range coll.collectors {
collectors := make([]collector.Collector, 0, len(coll.Collectors))
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look like this variable is being used anywhere, am i missing something?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed!

Comment on lines +14 to +23
var exchangeList = Config{
Name: "collectors.exchange.list",
HelpText: "List the collectors along with their perflib object name/ids",
Default: "false",
}
var exchangeEnabled = Config{
Name: "collectors.exchange.enabled",
HelpText: "Comma-separated list of collectors to use. Defaults to all, if not specified.",
Default: "",
}
Copy link
Member

Choose a reason for hiding this comment

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

Exposing the configs this way makes me nervous:

  • It isn't strongly typed, so importers don't know if they got a flag name wrong until runtime
  • All usage of kingpin has to be swapped out with this internal config lib, which makes it harder to justify upstream (it has the appearance of a more disruptive change rather than just shifting logic around)

I'd strongly recommend avoiding doing things this way and to use Prometheus' service discovery mechanism as inspiration:

  1. Create public per-collector config structs with public fields for each tunable
  2. Add a RegisterFlags method (or similar) that binds the values of the field to a flag.
  3. Add a Build or NewCollector method that creates the collector, passing the config to it as an argument.

Copy link
Author

Choose a reason for hiding this comment

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

Each config needs to pass 3 things: name, default and helptext. Will try to see how to make that work with using the mechanism linked above. Also isnt one of the purposes to have no usage of kingpin in the individual collectors to prevent possible kingpin overlap?

Copy link
Member

Choose a reason for hiding this comment

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

Each config needs to pass 3 things: name, default and helptext.

IMO only the default is relevant here, but isn't strictly necessary for using as a library.

Also isnt one of the purposes to have no usage of kingpin in the individual collectors to prevent possible kingpin overlap?

Yes, but the method to register flags should accept a kingpin application as an argument to avoid this problem. (You can also just avoid calling the register flags method entirely from the library, like we would do, since we'll be unmarshaling config from YAML instead)

@mattdurham mattdurham merged commit f2c015a into grafana:master Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants