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

Disable kine metrics by default #154

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,26 @@ var (
}
}

var metricsServer *http.Server

if rootCmdOpts.metrics {
go func() {
logrus.WithField("address", rootCmdOpts.metricsAddress).Print("Enable metrics endpoint")
mux := http.NewServeMux()
metricsServer := &http.Server{
Addr: rootCmdOpts.metricsAddress,
Handler: http.NewServeMux(),
}
mux, ok := metricsServer.Handler.(*http.ServeMux)
if !ok {
logrus.Fatal("Failed to create metrics endpoint")
} else {
mux.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(rootCmdOpts.metricsAddress, mux)
}()

go func() {
logrus.WithField("address", rootCmdOpts.metricsAddress).Print("Enable metrics endpoint")
if err := metricsServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
logrus.WithError(err).Fatal("Failed to start metrics endpoint")
}
}()
}
}

instance, err := server.New(
Expand Down Expand Up @@ -130,6 +143,11 @@ var (
logrus.WithError(err).Warning("Failed to shutdown OpenTelemetry SDK")
}
}
if rootCmdOpts.metrics && metricsServer != nil {
louiseschmidtgen marked this conversation as resolved.
Show resolved Hide resolved
if err := metricsServer.Shutdown(stopCtx); err != nil {
logrus.WithError(err).Fatal("Failed to shutdown metrics endpoint")
}
}
},
}
)
Expand All @@ -152,15 +170,15 @@ func init() {
rootCmd.Flags().BoolVar(&rootCmdOpts.diskMode, "disk-mode", false, "(experimental) run dqlite store in disk mode")
rootCmd.Flags().UintVar(&rootCmdOpts.clientSessionCacheSize, "tls-client-session-cache-size", 0, "ClientCacheSession size for dial TLS config")
rootCmd.Flags().StringVar(&rootCmdOpts.minTLSVersion, "min-tls-version", "tls12", "Minimum TLS version for dqlite endpoint (tls10|tls11|tls12|tls13). Default is tls12")
rootCmd.Flags().BoolVar(&rootCmdOpts.metrics, "metrics", true, "enable metrics endpoint")
rootCmd.Flags().BoolVar(&rootCmdOpts.metrics, "metrics", false, "enable metrics endpoint")
rootCmd.Flags().BoolVar(&rootCmdOpts.otel, "otel", false, "enable traces endpoint")
rootCmd.Flags().StringVar(&rootCmdOpts.otelAddress, "otel-listen", "127.0.0.1:4317", "listen address for OpenTelemetry endpoint")
rootCmd.Flags().StringVar(&rootCmdOpts.metricsAddress, "metrics-listen", "127.0.0.1:9042", "listen address for metrics endpoint")
rootCmd.Flags().DurationVar(&rootCmdOpts.watchAvailableStorageInterval, "watch-storage-available-size-interval", 5*time.Second, "Interval to check if the disk is running low on space. Set to 0 to disable the periodic disk size check")
rootCmd.Flags().Uint64Var(&rootCmdOpts.watchAvailableStorageMinBytes, "watch-storage-available-size-min-bytes", 10*1024*1024, "Minimum required available disk size (in bytes) to continue operation. If available disk space gets below this threshold, then the --low-available-storage-action is performed")
rootCmd.Flags().StringVar(&rootCmdOpts.lowAvailableStorageAction, "low-available-storage-action", "none", "Action to perform in case the available storage is low. One of (none|handover|terminate). none means no action is performed. handover means the dqlite node will handover its leadership role, if any. terminate means this dqlite node will shutdown")
rootCmd.Flags().StringVar(&rootCmdOpts.admissionControlPolicy, "admission-control-policy", "allow-all", "Transaction admission control policy to use. One of (allow-all|limit-concurrent-transactions). Set to allow-all to disable the admission control")
// TODO(MK-1408): This value is highly dependend on underlying hardware, thus making the default value a bit useless. The linked card will implement a dynamic way to set this value.
// TODO(MK-1408): This value is highly depends on underlying hardware, thus making the default value a bit useless. The linked card will implement a dynamic way to set this value.
louiseschmidtgen marked this conversation as resolved.
Show resolved Hide resolved
rootCmd.Flags().Int64Var(&rootCmdOpts.acpLimitMaxConcurrentTxn, "admission-control-policy-limit-max-concurrent-transactions", 300, "Maximum number of transactions that are allowed to run concurrently. Transactions will not be admitted after the limit is reached.")
rootCmd.Flags().BoolVar(&rootCmdOpts.acpOnlyWriteQueries, "admission-control-only-for-write-queries", false, "If set, admission control will only be applied to write queries.")

Expand Down
Loading