diff --git a/api/api_controller.go b/api/api_controller.go index 2823b087351..ae41975d891 100644 --- a/api/api_controller.go +++ b/api/api_controller.go @@ -263,8 +263,6 @@ func (c *Controller) SetupLakeFSHandler() setupop.SetupLakeFSHandler { }) } - c.deps.Collector.CollectEvent("global", "init") - username := swag.StringValue(setupReq.User.Username) var cred *model.Credential if setupReq.User.Key == nil { @@ -276,7 +274,13 @@ func (c *Controller) SetupLakeFSHandler() setupop.SetupLakeFSHandler { return setupop.NewSetupLakeFSDefault(http.StatusInternalServerError). WithPayload(&models.Error{Message: err.Error()}) } - + metadata, err := c.deps.MetadataManager.Write() + if err != nil { + c.deps.logger.Error("failed to write metadata after setup") + } else { + c.deps.Collector.SetInstallationID(metadata[auth.InstallationIDKeyName]) + } + c.deps.Collector.CollectEvent("global", "init") return setupop.NewSetupLakeFSOK().WithPayload(&models.CredentialsWithSecret{ AccessKeyID: cred.AccessKeyID, AccessSecretKey: cred.AccessSecretKey, diff --git a/api/handler_test.go b/api/handler_test.go index 0be8a117bde..fee41a4135f 100644 --- a/api/handler_test.go +++ b/api/handler_test.go @@ -76,6 +76,8 @@ func (m *mockCollector) CollectMetadata(_ *stats.Metadata) {} func (m *mockCollector) CollectEvent(_, _ string) {} +func (m *mockCollector) SetInstallationID(_ string) {} + func getHandler(t *testing.T, blockstoreType string, opts ...testutil.GetDBOption) (http.Handler, *dependencies) { conn, handlerDatabaseURI := testutil.GetDB(t, databaseURI, opts...) var blockAdapter block.Adapter diff --git a/gateway/playback_test.go b/gateway/playback_test.go index fc48970622f..39374ae3f39 100644 --- a/gateway/playback_test.go +++ b/gateway/playback_test.go @@ -99,6 +99,8 @@ func (m *mockCollector) CollectMetadata(accountMetadata *stats.Metadata) {} func (m *mockCollector) CollectEvent(class, action string) {} +func (m *mockCollector) SetInstallationID(_ string) {} + func getBasicHandlerPlayback(t *testing.T) (http.Handler, *dependencies) { authService := newGatewayAuthFromFile(t, simulator.PlaybackParams.RecordingDir) return getBasicHandler(t, authService) diff --git a/loadtest/local_load_test.go b/loadtest/local_load_test.go index cc573851b28..9d8daf367f8 100644 --- a/loadtest/local_load_test.go +++ b/loadtest/local_load_test.go @@ -49,6 +49,8 @@ func (m *mockCollector) CollectMetadata(_ *stats.Metadata) {} func (m *mockCollector) CollectEvent(_, _ string) {} +func (m *mockCollector) SetInstallationID(_ string) {} + func TestLocalLoad(t *testing.T) { if testing.Short() { t.Skip("Skipping loadtest tests in short mode") diff --git a/stats/collector.go b/stats/collector.go index ef760aff579..2a99c14df31 100644 --- a/stats/collector.go +++ b/stats/collector.go @@ -23,6 +23,7 @@ const ( type Collector interface { CollectEvent(class, action string) CollectMetadata(accountMetadata *Metadata) + SetInstallationID(installationID string) } type Metric struct { @@ -218,6 +219,10 @@ func (s *BufferedCollector) collectHeartbeat(ctx context.Context) { } } +func (s *BufferedCollector) SetInstallationID(installationID string) { + s.installationID = installationID +} + func getBufferedCollectorArgs(c *config.Config) (processID string, opts []BufferedCollectorOpts) { if c == nil { return "", nil