The code is more readable as it's more broken up by function.
We could move these options to YAML one day and update them at runtime instead of at startup.
Changes:
Ensures all flag values have their own struct.
Move flag validation and defaulting to their own methods.
Ensure all flag structs have only serializable values (e.g. ExporterOpts.Lease was moved out).
Use URLs with kingpin (flag library) to avoid needing to parse strings manually.
I also broke up the monstrosity that was the setup package exporter constructor which returned a function that would create an exporter. The reason this was done was because first we setup flags and then returned a method that would create the exporter once the flags were parsed. Now you can just call SetupFlags and then call exporter.New.
Tested a Prometheus version built with these changes with e2e tests, and they pass.
This PR cleans up all export flags so that:
Changes:
ExporterOpts.Lease
was moved out).kingpin
(flag library) to avoid needing to parse strings manually.I also broke up the monstrosity that was the
setup
package exporter constructor which returned a function that would create an exporter. The reason this was done was because first we setup flags and then returned a method that would create the exporter once the flags were parsed. Now you can just callSetupFlags
and then callexporter.New
.Tested a Prometheus version built with these changes with
e2e
tests, and they pass.