Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: multi-workspace fixes for settings, telemetry, cache, and resource ID conflicts (#19709)
ecmadao8e7063fc91b3
diff --git a/backend/api/auth/header.go b/backend/api/auth/header.goindex 6ed237146d..0ec9cb975c 100644--- a/backend/api/auth/header.go+++ b/backend/api/auth/header.go@@ -22,14 +22,15 @@ func GetTokenCookie(ctx context.Context, stores *store.Store, licenseService *en}}isHTTPS := strings.HasPrefix(origin, "https")- tokenDuration := GetAccessTokenDuration(ctx, stores, licenseService, workspaceID)+ // Cookie expiry matches the refresh token duration so that Refresh() can always+ // extract the workspace from the expired JWT, even after long idle periods.+ // The auth middleware rejects expired JWTs for API calls, so a stale cookie is harmless.+ // The cookie is only read by Refresh() which verifies the signature but skips expiry.+ cookieDuration := GetRefreshTokenDuration(ctx, stores, licenseService, workspaceID)return &http.Cookie{- Name: AccessTokenCookieName,- Value: token,- // Cookie outlives the JWT by 30 seconds so that Refresh() can extract the- // workspace from the expired token. The frontend calls Refresh immediately- // on 401, well within this window.- Expires: time.Now().Add(tokenDuration + 30*time.Second),+ Name: AccessTokenCookieName,+ Value: token,+ Expires: time.Now().Add(cookieDuration),Path: "/",// Http-only helps mitigate the risk of client side script accessing the protected cookie.HttpOnly: true,diff --git a/backend/api/v1/actuator_service.go b/backend/api/v1/actuator_service.goindex a635d70ff5..bd987936b7 100644--- a/backend/api/v1/actuator_service.go+++ b/backend/api/v1/actuator_service.go@@ -106,7 +106,7 @@ func (s *ActuatorService) GetResourcePackage(return nil, connect.NewError(connect.CodeInternal, err)}workspaceID = ws- } else if req.Msg.Name == "" {+ } else if req.Msg.Name != "" {reqWorkspaceID, err := common.GetWorkspaceID(req.Msg.Name)if err != nil {return nil, connect.NewError(connect.CodeInvalidArgument, err)diff --git a/backend/api/v1/idp_service.go b/backend/api/v1/idp_service.goindex 616a27041d..467e7c0f43 100644--- a/backend/api/v1/idp_service.go+++ b/backend/api/v1/idp_service.go@@ -109,6 +109,9 @@ func (s *IdentityProviderService) CreateIdentityProvider(ctx context.Context, reidentityProviderMessage, err := s.store.CreateIdentityProvider(ctx, identityProviderMessage)if err != nil {+ if strings.Contains(err.Error(), "duplicate key") {+ return nil, connect.NewError(connect.CodeAlreadyExists, errors.Errorf("identity provider ID %q already exists", req.Msg.IdentityProviderId))+ }return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to create identity provider"))}identityProvider := convertToIdentityProvider(identityProviderMessage)diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.goindex f6bfaf0ad9..3cedb5f08b 100644--- a/backend/api/v1/instance_service.go+++ b/backend/api/v1/instance_service.go@@ -213,6 +213,9 @@ func (s *InstanceService) CreateInstance(ctx context.Context, req *connect.RequeinstanceMessage.Workspace = workspaceIDinstance, err := s.store.CreateInstance(ctx, instanceMessage)if err != nil {+ if strings.Contains(err.Error(), "duplicate key") {+ return nil, connect.NewError(connect.CodeAlreadyExists, errors.Errorf("instance ID %q already exists", req.Msg.InstanceId))+ }return nil, connect.NewError(connect.CodeInternal, err)}diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex 1fecb2e021..d4b9f9daee 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -242,6 +242,9 @@ func (s *ProjectService) CreateProject(ctx context.Context, req *connect.Requestuser,)if err != nil {+ if strings.Contains(err.Error(), "duplicate key") {+ return nil, connect.NewError(connect.CodeAlreadyExists, errors.Errorf("project ID %q already exists", req.Msg.ProjectId))+ }return nil, connect.NewError(connect.CodeInternal, err)}return connect.NewResponse(convertToProject(project)), nildiff --git a/backend/api/v1/review_config_service.go b/backend/api/v1/review_config_service.goindex baee9917a8..d46828935e 100644--- a/backend/api/v1/review_config_service.go+++ b/backend/api/v1/review_config_service.go@@ -45,6 +45,9 @@ func (s *ReviewConfigService) CreateReviewConfig(ctx context.Context, req *connecreated, err := s.store.CreateReviewConfig(ctx, reviewConfigMessage)if err != nil {+ if strings.Contains(err.Error(), "duplicate key") {+ return nil, connect.NewError(connect.CodeAlreadyExists, errors.Errorf("review config ID %q already exists", reviewConfigMessage.ID))+ }return nil, connect.NewError(connect.CodeInternal, err)}result, err := s.convertToV1ReviewConfig(ctx, created)diff --git a/backend/api/v1/role_service.go b/backend/api/v1/role_service.goindex 1f8c6242b8..192b482e6d 100644--- a/backend/api/v1/role_service.go+++ b/backend/api/v1/role_service.go@@ -108,6 +108,9 @@ func (s *RoleService) CreateRole(ctx context.Context, req *connect.Request[v1pb.}roleMessage, err := s.store.CreateRole(ctx, create)if err != nil {+ if strings.Contains(err.Error(), "duplicate key") {+ return nil, connect.NewError(connect.CodeAlreadyExists, errors.Errorf("role ID %q already exists", req.Msg.RoleId))+ }return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to create role"))}if err := s.iamManager.ReloadCache(ctx); err != nil {diff --git a/backend/api/v1/service_account_service.go b/backend/api/v1/service_account_service.goindex 34d0dea342..402bc00428 100644--- a/backend/api/v1/service_account_service.go+++ b/backend/api/v1/service_account_service.go@@ -11,6 +11,7 @@ import ("google.golang.org/protobuf/types/known/emptypb""github.com/bytebase/bytebase/backend/common"+ "github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/iam"v1pb "github.com/bytebase/bytebase/backend/generated-go/v1""github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"@@ -21,13 +22,15 @@ import (type ServiceAccountService struct {v1connect.UnimplementedServiceAccountServiceHandlerstore *store.Store+ profile *config.ProfileiamManager *iam.Manager}// NewServiceAccountService creates a new ServiceAccountService.-func NewServiceAccountService(store *store.Store, iamManager *iam.Manager) *ServiceAccountService {+func NewServiceAccountService(store *store.Store, profile *config.Profile, iamManager *iam.Manager) *ServiceAccountService {return &ServiceAccountService{store: store,+ profile: profile,iamManager: iamManager,}}@@ -52,6 +55,10 @@ func (s *ServiceAccountService) CreateServiceAccount(ctx context.Context, requesreturn nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid parent format %q, expected projects/{project} or workspaces/{id}", parent))}+ if projectID == nil && s.profile.SaaS {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("donot support create workload identity in workspace"))+ }+serviceAccountID := request.Msg.ServiceAccountIdif serviceAccountID == "" {return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("service_account_id is required"))diff --git a/backend/api/v1/subscription_service.go b/backend/api/v1/subscription_service.goindex 17263ebba2..a512372e57 100644--- a/backend/api/v1/subscription_service.go+++ b/backend/api/v1/subscription_service.go@@ -39,10 +39,7 @@ func (s *SubscriptionService) GetSubscription(ctx context.Context, _ *connect.Re// UpdateSubscription updates the subscription license.func (s *SubscriptionService) UpdateSubscription(ctx context.Context, req *connect.Request[v1pb.UpdateSubscriptionRequest]) (*connect.Response[v1pb.Subscription], error) {- if s.profile.SaaS {- // TODO(ed): allowed in SaaS v2- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("cannot update license in the SaaS mode"))- }+ // TODO(ed): disable UpdateSubscription once we support purchase license in SaaS V2if err := s.licenseService.StoreLicense(ctx, common.GetWorkspaceIDFromContext(ctx), req.Msg.License); err != nil {if common.ErrorCode(err) == common.Invalid {return nil, connect.NewError(connect.CodeInvalidArgument, err)diff --git a/backend/api/v1/workload_identity_service.go b/backend/api/v1/workload_identity_service.goindex 3d98f5f909..cae2bacdce 100644--- a/backend/api/v1/workload_identity_service.go+++ b/backend/api/v1/workload_identity_service.go@@ -9,6 +9,7 @@ import ("google.golang.org/protobuf/types/known/emptypb""github.com/bytebase/bytebase/backend/common"+ "github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/iam"storepb "github.com/bytebase/bytebase/backend/generated-go/store"v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"@@ -20,13 +21,15 @@ import (type WorkloadIdentityService struct {v1connect.UnimplementedWorkloadIdentityServiceHandlerstore *store.Store+ profile *config.ProfileiamManager *iam.Manager}// NewWorkloadIdentityService creates a new WorkloadIdentityService.-func NewWorkloadIdentityService(store *store.Store, iamManager *iam.Manager) *WorkloadIdentityService {+func NewWorkloadIdentityService(store *store.Store, profile *config.Profile, iamManager *iam.Manager) *WorkloadIdentityService {return &WorkloadIdentityService{store: store,+ profile: profile,iamManager: iamManager,}}@@ -51,6 +54,10 @@ func (s *WorkloadIdentityService) CreateWorkloadIdentity(ctx context.Context, rereturn nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid parent format %q, expected projects/{project} or workspaces/{id}", parent))}+ if projectID == nil && s.profile.SaaS {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("donot support create workload identity in workspace"))+ }+workloadIdentityID := request.Msg.WorkloadIdentityIdif workloadIdentityID == "" {return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("workload_identity_id is required"))diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.goindex bac784140a..e72f8b88f0 100644--- a/backend/bin/server/cmd/profile.go+++ b/backend/bin/server/cmd/profile.go@@ -11,19 +11,19 @@ import (func getBaseProfile(dataDir string) *config.Profile {config := &config.Profile{- ExternalURL: flags.externalURL,- Port: flags.port, // Using flags.port as our gRPC server port.- DatastorePort: flags.port + 2, // Using flags.port + 2 as our datastore port.- HA: flags.ha,- SaaS: flags.saas,- EnableJSONLogging: flags.enableJSONLogging,- IsDocker: isDocker(),- DataDir: dataDir,- Demo: flags.demo,- Version: version,- GitCommit: gitcommit,- PgURL: os.Getenv("PG_URL"),- ReplicaID: uuid.NewString(),+ ExternalURL: flags.externalURL,+ Port: flags.port, // Using flags.port as our gRPC server port.+ DatastorePort: flags.port + 2, // Using flags.port + 2 as our datastore port.+ HA: flags.ha,+ SaaS: flags.saas,+ Debug: flags.debug,+ IsDocker: isDocker(),+ DataDir: dataDir,+ Demo: flags.demo,+ Version: version,+ GitCommit: gitcommit,+ PgURL: os.Getenv("PG_URL"),+ ReplicaID: uuid.NewString(),}config.LastActiveTS.Store(time.Now().Unix())diff --git a/backend/bin/server/cmd/root.go b/backend/bin/server/cmd/root.goindex da84d35723..5dc6e3219c 100644--- a/backend/bin/server/cmd/root.go+++ b/backend/bin/server/cmd/root.go@@ -64,6 +64,7 @@ var (dataDir stringha boolsaas bool+ debug bool// output logs in json formatenableJSONLogging bool// demo mode.@@ -108,6 +109,7 @@ func init() {rootCmd.PersistentFlags().StringVar(&flags.dataDir, "data", defaultDataDir, "not recommended for production. Directory where Bytebase stores data if PG_URL is not specified. If relative path is supplied, then the path is relative to the directory where Bytebase is under")rootCmd.PersistentFlags().BoolVar(&flags.ha, "ha", false, "run in HA mode")rootCmd.PersistentFlags().BoolVar(&flags.saas, "saas", false, "run in SaaS mode")+ rootCmd.PersistentFlags().BoolVar(&flags.debug, "debug", false, "enable debug level log")rootCmd.PersistentFlags().BoolVar(&flags.enableJSONLogging, "enable-json-logging", false, "enable output logs in bytebase in json format")// Must be one of the subpath name in the ../migrator/demo directoryrootCmd.PersistentFlags().BoolVar(&flags.demo, "demo", false, "run in demo mode.")diff --git a/backend/component/config/profile.go b/backend/component/config/profile.goindex 751f508818..6180ecdbd3 100644--- a/backend/component/config/profile.go+++ b/backend/component/config/profile.go@@ -21,14 +21,14 @@ type Profile struct {Port int// When we are running in SaaS mode, some features are not allowed to edit by users.SaaS bool- // When enabled output logs in json format- EnableJSONLogging bool// DataDir is the directory stores the data including Bytebase's own database, backups, etc.DataDir string// Demo mode.Demo bool// HA replica mode.HA bool+ // Enable debug level. Only works when SaaS is true.+ Debug bool// Version is the bytebase's server versionVersion stringdiff --git a/backend/component/telemetry/reporter.go b/backend/component/telemetry/reporter.goindex 8256c71c7f..991dce4f5a 100644--- a/backend/component/telemetry/reporter.go+++ b/backend/component/telemetry/reporter.go@@ -25,11 +25,10 @@ const (// Reporter sends telemetry events to hub.bytebase.com with deduplication.type Reporter struct {- mu sync.RWMutex- workspaceID string- version string- gitCommit string- enabled bool+ mu sync.RWMutex+ version string+ gitCommit string+ enabled bool// LRU cache for deduplication: tracks reported statement hashescache *lru.Cache[string, struct{}]@@ -43,16 +42,16 @@ var ()// InitGlobalReporter initializes the global telemetry reporter.-// Must be called once at server startup.-func InitGlobalReporter(workspaceID, version, gitCommit string, enabled bool) {+// The workspace ID is not needed at init time — it's resolved from request context+// when events are reported, so this works in both single-workspace and SaaS modes.+func InitGlobalReporter(version, gitCommit string, enabled bool) {globalReporterOnce.Do(func() {cache, _ := lru.New[string, struct{}](cacheCapacity)globalReporter = &Reporter{- workspaceID: workspaceID,- version: version,- gitCommit: gitCommit,- enabled: enabled,- cache: cache,+ version: version,+ gitCommit: gitCommit,+ enabled: enabled,+ cache: cache,httpClient: &http.Client{Timeout: 10 * time.Second,},@@ -75,17 +74,18 @@ type gomongoFallbackPayload struct {// ReportGomongoFallback reports a gomongo fallback event.// It deduplicates based on statement hash using an LRU cache.// Only reports in release versions (non-development builds).-func ReportGomongoFallback(ctx context.Context, statement string, errorMessage string) {+// The workspace ID is resolved from the request context if available,+// otherwise from the explicit workspaceID parameter (for runner contexts).+func ReportGomongoFallback(ctx context.Context, workspaceID, statement, errorMessage string) {if globalReporter == nil {return}globalReporter.mu.RLock()- if !globalReporter.enabled || globalReporter.workspaceID == "" {+ if !globalReporter.enabled {globalReporter.mu.RUnlock()return}- workspaceID := globalReporter.workspaceIDversion := globalReporter.versiongitCommit := globalReporter.gitCommitglobalReporter.mu.RUnlock()@@ -95,6 +95,14 @@ func ReportGomongoFallback(ctx context.Context, statement string, errorMessage sreturn}+ // Prefer workspace from context (API requests), fall back to parameter (runners).+ if wsFromCtx := common.GetWorkspaceIDFromContext(ctx); wsFromCtx != "" {+ workspaceID = wsFromCtx+ }+ if workspaceID == "" {+ return+ }+// Truncate statementtruncatedStatement, truncated := common.TruncateString(statement, maxStatementLength)if truncated {diff --git a/backend/migrator/migration/3.17/0010##setting_composite_pk.sql b/backend/migrator/migration/3.17/0010##setting_composite_pk.sqlnew file mode 100644index 0000000000..5742df15f1--- /dev/null+++ b/backend/migrator/migration/3.17/0010##setting_composite_pk.sql@@ -0,0 +1,9 @@+-- Change setting PK from (name) to (workspace, name) for multi-workspace support.+ALTER TABLE setting DROP CONSTRAINT IF EXISTS setting_pkey;+DO $$+BEGIN+ ALTER TABLE setting ADD PRIMARY KEY (workspace, name);+EXCEPTION WHEN duplicate_table THEN+ -- PK already exists.+END $$;+DROP INDEX IF EXISTS idx_setting_unique_workspace_name;diff --git a/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sqlindex 36d81827ae..f3c5c20e2e 100644--- a/backend/migrator/migration/LATEST.sql+++ b/backend/migrator/migration/LATEST.sql@@ -44,13 +44,13 @@ CREATE TABLE setting (-- name: SYSTEM, WORKSPACE_PROFILE, WORKSPACE_APPROVAL,-- APP_IM, AI, DATA_CLASSIFICATION, SEMANTIC_TYPES, ENVIRONMENT-- Enum: SettingName (proto/store/store/setting.proto)- name text NOT NULL PRIMARY KEY,+ name text NOT NULL,workspace text NOT NULL REFERENCES workspace(resource_id),-- Stored as JSON marshalled by protojson.Marshal (camelCase keys)- value jsonb NOT NULL+ value jsonb NOT NULL,+ PRIMARY KEY (workspace, name));-CREATE UNIQUE INDEX idx_setting_unique_workspace_name ON setting(workspace, name);CREATE INDEX idx_setting_workspace ON setting(workspace);-- Role@@ -354,7 +354,7 @@ CREATE INDEX idx_worksheet_organizer_payload ON worksheet_organizer USING GIN(paCREATE TABLE db_group (project text NOT NULL REFERENCES project(resource_id),- -- global unique+ -- project-level uniqueresource_id text NOT NULL,name text NOT NULL DEFAULT '',-- Stored as google.type.Expr (from Google Common Expression Language)diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 3e7d2329d5..7e14268ea0 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -15,8 +15,8 @@ import (func TestLatestVersion(t *testing.T) {files, err := getSortedVersionedFiles()require.NoError(t, err)- require.Equal(t, semver.MustParse("3.17.9"), *files[len(files)-1].version)- require.Equal(t, "migration/3.17/0009##add_workspace_table.sql", files[len(files)-1].path)+ require.Equal(t, semver.MustParse("3.17.10"), *files[len(files)-1].version)+ require.Equal(t, "migration/3.17/0010##setting_composite_pk.sql", files[len(files)-1].path)}func TestVersionUnique(t *testing.T) {diff --git a/backend/plugin/db/mongodb/mongodb.go b/backend/plugin/db/mongodb/mongodb.goindex cd53588932..2ece1fbd46 100644--- a/backend/plugin/db/mongodb/mongodb.go+++ b/backend/plugin/db/mongodb/mongodb.go@@ -117,7 +117,7 @@ func (d *Driver) Execute(ctx context.Context, statement string, opts db.ExecuteO// gomongo doesn't support this operation; fall back to mongosh.if mongoshErr := d.executeWithMongoshSingle(ctx, stmt.Text); mongoshErr == nil {slog.Debug("executed statement with mongosh fallback", slog.String("statement", stmt.Text), log.BBError(gomongoErr))- telemetry.ReportGomongoFallback(ctx, stmt.Text, gomongoErr.Error())+ telemetry.ReportGomongoFallback(ctx, "", stmt.Text, gomongoErr.Error())gomongoErr = nil} else {gomongoErr = mongoshErr@@ -319,7 +319,7 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, qresults, err := d.queryConnWithMongosh(ctx, statement, queryContext, startTime)if err == nil && gomongoErr != nil {slog.Debug("executed query with mongosh fallback", slog.String("statement", statement), log.BBError(gomongoErr))- telemetry.ReportGomongoFallback(ctx, statement, gomongoErr.Error())+ telemetry.ReportGomongoFallback(ctx, "", statement, gomongoErr.Error())}return results, err}diff --git a/backend/server/grpc_routes.go b/backend/server/grpc_routes.goindex d96984a7d3..79a5dc8d0e 100644--- a/backend/server/grpc_routes.go+++ b/backend/server/grpc_routes.go@@ -114,8 +114,8 @@ func configureGrpcRouters(sqlService := apiv1.NewSQLService(stores, schemaSyncer, dbFactory, licenseService, iamManager)subscriptionService := apiv1.NewSubscriptionService(profile, licenseService)userService := apiv1.NewUserService(stores, licenseService, profile, iamManager)- serviceAccountService := apiv1.NewServiceAccountService(stores, iamManager)- workloadIdentityService := apiv1.NewWorkloadIdentityService(stores, iamManager)+ serviceAccountService := apiv1.NewServiceAccountService(stores, profile, iamManager)+ workloadIdentityService := apiv1.NewWorkloadIdentityService(stores, profile, iamManager)worksheetService := apiv1.NewWorksheetService(stores, iamManager)workspaceService := apiv1.NewWorkspaceService(stores, iamManager, profile)diff --git a/backend/server/server.go b/backend/server/server.goindex dea108d381..fb490f4400 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -154,6 +154,11 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {s.store = storessheetManager := sheet.NewManager()+ logSetup := &storepb.WorkspaceProfileSetting{+ EnableAuditLogStdout: false,+ EnableMetricCollection: true,+ EnableDebug: profile.Debug,+ }if !s.profile.SaaS {s.sampleInstanceManager = sampleinstance.NewManager(stores, profile)@@ -165,26 +170,25 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {slog.Warn("failed to start sample instances", log.BBError(err))}- if workspaceProfile, err := s.store.GetWorkspaceProfileSetting(ctx, workspaceID); err == nil {- profile.RuntimeDebug.Store(workspaceProfile.EnableDebug)- if workspaceProfile.EnableDebug {- log.LogLevel.Set(slog.LevelDebug)- }- if workspaceProfile.GetEnableAuditLogStdout() {- if err := s.licenseService.IsFeatureEnabled(ctx, workspaceID, v1pb.PlanFeature_FEATURE_AUDIT_LOG); err == nil {- s.profile.RuntimeEnableAuditLogStdout.Store(true)- }+ if workspaceProfileSetting, err := s.store.GetWorkspaceProfileSetting(ctx, workspaceID); err == nil {+ logSetup = workspaceProfileSetting+ if logSetup.GetEnableAuditLogStdout() && s.licenseService.IsFeatureEnabled(ctx, workspaceID, v1pb.PlanFeature_FEATURE_AUDIT_LOG) == nil {+ s.profile.RuntimeEnableAuditLogStdout.Store(true)}- telemetry.InitGlobalReporter(- workspaceID,- profile.Version,- profile.GitCommit,- workspaceProfile.GetEnableMetricCollection(),- )}}}+ profile.RuntimeDebug.Store(logSetup.EnableDebug)+ if logSetup.EnableDebug {+ log.LogLevel.Set(slog.LevelDebug)+ }+ telemetry.InitGlobalReporter(+ profile.Version,+ profile.GitCommit,+ logSetup.GetEnableMetricCollection(),+ )+s.bus, err = bus.New()if err != nil {return nil, errors.Wrapf(err, "failed to create message bus")