Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add flag to disable the metric (#2331)
ecmadao6b8714a605d3
diff --git a/bin/server/cmd/profile.go b/bin/server/cmd/profile.goindex 50db4c9982..0760349186 100644--- a/bin/server/cmd/profile.go+++ b/bin/server/cmd/profile.go@@ -35,6 +35,7 @@ func getBaseProfile() server.Profile {GitCommit: gitcommit,PgURL: flags.pgURL,BackupStorageBackend: api.BackupStorageBackendLocal,+ DisableMetric: flags.disableMetric,}}diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.goindex 41b13074ab..50ee088f50 100644--- a/bin/server/cmd/root.go+++ b/bin/server/cmd/root.go@@ -96,6 +96,8 @@ var (// pgURL must follow PostgreSQL connection URIs pattern.// https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRINGpgURL string+ // disableMetric is the flag to disable the metric collector.+ disableMetric bool}rootCmd = &cobra.Command{Use: "bytebase",@@ -131,6 +133,7 @@ func init() {rootCmd.PersistentFlags().StringVar(&flags.demoName, "demo-name", "", "name of the demo to use when running in demo mode")rootCmd.PersistentFlags().BoolVar(&flags.debug, "debug", false, "whether to enable debug level logging")rootCmd.PersistentFlags().StringVar(&flags.pgURL, "pg", "", "optional external PostgreSQL instance connection url(must provide dbname); for example postgresql://user:secret@masterhost:5432/dbname?sslrootcert=cert")+ rootCmd.PersistentFlags().BoolVar(&flags.disableMetric, "disable-metric", false, "disable the metric collector")}// -----------------------------------Command Line Config END--------------------------------------diff --git a/server/config.go b/server/config.goindex 6f2419e5e9..a77d95d129 100644--- a/server/config.go+++ b/server/config.go@@ -62,6 +62,8 @@ type Profile struct {PgURL string// MetricConnectionKey is the connection key for metric.MetricConnectionKey string+ // DisableMetric will disable the metric collector.+ DisableMetric bool}func (prof *Profile) useEmbedDB() bool {diff --git a/server/server.go b/server/server.goindex d55e211b15..018347b9ff 100644--- a/server/server.go+++ b/server/server.go@@ -362,7 +362,7 @@ func (s *Server) initSubscription() {// initMetricReporter will initial the metric scheduler.func (s *Server) initMetricReporter(workspaceID string) {- enabled := s.profile.Mode == common.ReleaseModeProd && !s.profile.Demo+ enabled := s.profile.Mode == common.ReleaseModeProd && !s.profile.Demo && !s.profile.DisableMetricif enabled {metricReporter := NewMetricReporter(s, workspaceID)metricReporter.Register(metric.InstanceCountMetricName, metricCollector.NewInstanceCountCollector(s.store))