diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b0923e..67c4135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ 1.5 === +* Deprecate `-no-exit`. Default behavior is not to exit on scrape errors as it should be for a long running HTTP server. + * This was design misstep. You will not get a deprecation warning if you pass `-no-exit` but the process behaves as before. + * New explicit `-exit-on-errors` has been added for users who want the old default behavior back. * Correctly export gauge and counter types from `varnishstat` output `type` property. * Add go module support. * Use `github.com/prometheus/client_golang` v1.0.0 diff --git a/main.go b/main.go index 72abfd2..40f29c1 100644 --- a/main.go +++ b/main.go @@ -42,10 +42,12 @@ type startParams struct { Params *varnishstatParams Verbose bool - NoExit bool + ExitOnErrors bool Test bool Raw bool WithGoMetrics bool + + noExit bool // deprecated } type varnishstatParams struct { @@ -86,12 +88,15 @@ func init() { // modes version := false flag.BoolVar(&version, "version", version, "Print version and exit") - flag.BoolVar(&StartParams.NoExit, "no-exit", StartParams.NoExit, "Do not exit server on Varnish scrape errors.") + flag.BoolVar(&StartParams.ExitOnErrors, "exit-on-errors", StartParams.ExitOnErrors, "Exit process on scrape errors.") flag.BoolVar(&StartParams.Verbose, "verbose", StartParams.Verbose, "Verbose logging.") flag.BoolVar(&StartParams.Test, "test", StartParams.Test, "Test varnishstat availability, prints available metrics and exits.") flag.BoolVar(&StartParams.Raw, "raw", StartParams.Test, "Raw stdout logging without timestamps.") flag.BoolVar(&StartParams.WithGoMetrics, "with-go-metrics", StartParams.WithGoMetrics, "Export go runtime and http handler metrics") + // deprecated + flag.BoolVar(&StartParams.noExit, "no-exit", StartParams.noExit, "Deprecated: see -exit-on-errors") + flag.Parse() if version { @@ -111,10 +116,13 @@ func init() { logFatal("-web.telemetry-path and -web.health-path cannot have same value") } - // This looks weird, but we want the start param to have default value - // of the old behavior, not flip it with e.g. -exit. You have to - // explicitly turn on the changed behavior. - ExitHandler.exitOnError = StartParams.Test == true || StartParams.NoExit == false + // Don't log warning on !noExit as that would spam for the formed default value. + if StartParams.noExit { + logWarn("-no-exit is deprecated. As of v1.5 it is the default behavior not to exit process on scrape errors. You can remove this parameter.") + } + + // Test run or user explicitly wants to exit on any scrape errors during runtime. + ExitHandler.exitOnError = StartParams.Test == true || StartParams.ExitOnErrors == true } func main() {