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(metric): several improvement (#1349)
ecmadaofc96e00236ea
diff --git a/api/workspace.go b/api/workspace.godeleted file mode 100644index 7839fdb666..0000000000--- a/api/workspace.go+++ /dev/null@@ -1,7 +0,0 @@-package api--// Workspace is the instance for console application.-type Workspace struct {- Plan string- ID string-}diff --git a/server/metric_reporter.go b/server/metric_reporter.goindex c4b76c5f39..a45066e23d 100644--- a/server/metric_reporter.go+++ b/server/metric_reporter.go@@ -19,6 +19,8 @@ const (metricSchedulerInterval = time.Duration(1) * time.Hour// identifyTraitForPlan is the trait key for subscription plan.identifyTraitForPlan = "plan"+ // identifyTraitForVersion is the trait key for bytebase version.+ identifyTraitForVersion = "version")// MetricReporter is the metric reporter.@@ -28,9 +30,11 @@ type MetricReporter struct {// subscription is the pointer to the server.subscription.// the subscription can be updated by users so we need the pointer to get the latest value.subscription *enterpriseAPI.Subscription- workspaceID string- reporter reporter.MetricReporter- collectors map[string]collector.MetricCollector+ // Version is the bytebase's version+ version string+ workspaceID string+ reporter reporter.MetricReporter+ collectors map[string]collector.MetricCollector}// NewMetricReporter creates a new metric scheduler.@@ -40,6 +44,7 @@ func NewMetricReporter(logger *zap.Logger, server *Server, workspaceID string) *return &MetricReporter{l: logger,subscription: &server.subscription,+ version: server.profile.Version,workspaceID: workspaceID,reporter: r,collectors: make(map[string]collector.MetricCollector),@@ -121,7 +126,8 @@ func (m *MetricReporter) identify() {if err := m.reporter.Identify(&metricAPI.Identifier{ID: m.workspaceID,Labels: map[string]string{- identifyTraitForPlan: plan,+ identifyTraitForPlan: plan,+ identifyTraitForVersion: m.version,},}); err != nil {m.l.Debug("reporter identify failed", zap.Error(err))diff --git a/store/instance.go b/store/instance.goindex d5dff9ca07..d74f42c282 100644--- a/store/instance.go+++ b/store/instance.go@@ -165,7 +165,9 @@ func (s *Store) CountInstanceGroupByEngineAndEnvironmentID(ctx context.Context,rows, err := tx.PTx.QueryContext(ctx, `SELECT engine, environment_id, COUNT(*)FROM instance- WHERE row_status = $1+ WHERE row_status = $1 AND (+ (id <= 102 AND updater_id != 1) OR id > 102+ )GROUP BY engine, environment_id`,rowStatus,)