From 0a3a55bb80262051a74009a1bb404e7980eb457b Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 6 May 2024 09:46:16 -0400 Subject: [PATCH] MM-58092 Add feature flag and setting for client performance metrics (#26942) * MM-58092 Add feature flag and setting for client performance metrics * Fix incorrect field name --- server/config/client.go | 1 + server/public/model/config.go | 11 +++++++--- server/public/model/feature_flags.go | 3 +++ .../admin_console/admin_definition.tsx | 22 +++++++++++++++++++ webapp/channels/src/i18n/en.json | 2 ++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/server/config/client.go b/server/config/client.go index 8a975eb7b9..fff0f3d5fe 100644 --- a/server/config/client.go +++ b/server/config/client.go @@ -187,6 +187,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li if *license.Features.Cluster { props["EnableMetrics"] = strconv.FormatBool(*c.MetricsSettings.Enable) + props["EnableClientMetrics"] = strconv.FormatBool(c.FeatureFlags.ClientMetrics && *c.MetricsSettings.EnableClientMetrics) } if *license.Features.Announcement { diff --git a/server/public/model/config.go b/server/public/model/config.go index 4c0ae77ba4..61e01ec570 100644 --- a/server/public/model/config.go +++ b/server/public/model/config.go @@ -980,9 +980,10 @@ func (s *ClusterSettings) SetDefaults() { } type MetricsSettings struct { - Enable *bool `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` - BlockProfileRate *int `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` - ListenAddress *string `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` // telemetry: none + Enable *bool `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` + BlockProfileRate *int `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` + ListenAddress *string `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` // telemetry: none + EnableClientMetrics *bool `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` } func (s *MetricsSettings) SetDefaults() { @@ -997,6 +998,10 @@ func (s *MetricsSettings) SetDefaults() { if s.BlockProfileRate == nil { s.BlockProfileRate = NewInt(0) } + + if s.EnableClientMetrics == nil { + s.EnableClientMetrics = NewBool(true) + } } type ExperimentalSettings struct { diff --git a/server/public/model/feature_flags.go b/server/public/model/feature_flags.go index 8065f2a2aa..7fc70c4f8c 100644 --- a/server/public/model/feature_flags.go +++ b/server/public/model/feature_flags.go @@ -55,6 +55,8 @@ type FeatureFlags struct { WebSocketEventScope bool NotificationMonitoring bool + + ClientMetrics bool } func (f *FeatureFlags) SetDefaults() { @@ -78,6 +80,7 @@ func (f *FeatureFlags) SetDefaults() { f.ChannelBookmarks = false f.WebSocketEventScope = false f.NotificationMonitoring = true + f.ClientMetrics = false } // ToMap returns the feature flags as a map[string]string diff --git a/webapp/channels/src/components/admin_console/admin_definition.tsx b/webapp/channels/src/components/admin_console/admin_definition.tsx index 25c0f77419..a5706460a1 100644 --- a/webapp/channels/src/components/admin_console/admin_definition.tsx +++ b/webapp/channels/src/components/admin_console/admin_definition.tsx @@ -1788,6 +1788,28 @@ const AdminDefinition: AdminDefinitionType = { }, isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.ENVIRONMENT.PERFORMANCE_MONITORING)), }, + { + type: 'bool', + key: 'MetricsSettings.EnableClientMetrics', + label: defineMessage({id: 'admin.metrics.enableClientMetricsTitle', defaultMessage: 'Enable Client Performance Monitoring:'}), + help_text: defineMessage({id: 'admin.metrics.enableClientMetricsDescription', defaultMessage: 'When true, Mattermost will enable performance monitoring collection for web and desktop app users. Please see documentation to learn more about configuring performance monitoring for Mattermost.'}), + help_text_markdown: false, + help_text_values: { + link: (msg: string) => ( + + {msg} + + ), + }, + isDisabled: it.any( + it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.ENVIRONMENT.PERFORMANCE_MONITORING)), + it.configIsFalse('MetricsSettings', 'Enable'), + ), + isHidden: it.configIsFalse('FeatureFlags', 'ClientMetrics'), + }, { type: 'text', key: 'MetricsSettings.ListenAddress', diff --git a/webapp/channels/src/i18n/en.json b/webapp/channels/src/i18n/en.json index fc8a51599b..fe990bd570 100644 --- a/webapp/channels/src/i18n/en.json +++ b/webapp/channels/src/i18n/en.json @@ -1472,6 +1472,8 @@ "admin.manage_tokens.userAccessTokensNone": "No personal access tokens.", "admin.member_list_group.name": "Name", "admin.member_list_group.notFound": "No users found", + "admin.metrics.enableClientMetricsDescription": "When true, Mattermost will enable performance monitoring collection for web and desktop app users. Please see documentation to learn more about configuring performance monitoring for Mattermost.", + "admin.metrics.enableClientMetricsTitle": "Enable Client Performance Monitoring:", "admin.metrics.enableDescription": "When true, Mattermost will enable performance monitoring collection and profiling. Please see documentation to learn more about configuring performance monitoring for Mattermost.", "admin.metrics.enableTitle": "Enable Performance Monitoring:", "admin.metrics.listenAddressDesc": "The address the server will listen on to expose performance metrics.",