[MM-65979] Add Prometheus metrics for plugin webapp performance (#35075)
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Blocked by required conditions
Web App CI / check-types (push) Blocked by required conditions
Web App CI / test (platform) (push) Blocked by required conditions
Web App CI / test (mattermost-redux) (push) Blocked by required conditions
Web App CI / test (channels shard 1/4) (push) Blocked by required conditions
Web App CI / test (channels shard 2/4) (push) Blocked by required conditions
Web App CI / test (channels shard 3/4) (push) Blocked by required conditions
Web App CI / test (channels shard 4/4) (push) Blocked by required conditions
Web App CI / upload-coverage (push) Blocked by required conditions
Web App CI / build (push) Blocked by required conditions

This commit is contained in:
M-ZubairAhmed 2026-02-13 18:07:54 +05:30 committed by GitHub
parent 51426954cf
commit cd8b22af99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 0 deletions

View file

@ -157,6 +157,8 @@ func (a *App) RegisterPerformanceReport(rctx request.CTX, report *model.Performa
a.Metrics().ObserveDesktopCpuUsage(commonLabels["platform"], commonLabels["desktop_app_version"], h.Labels["process"], h.Value)
case model.DesktopClientMemoryUsage:
a.Metrics().ObserveDesktopMemoryUsage(commonLabels["platform"], commonLabels["desktop_app_version"], h.Labels["process"], h.Value/1000)
case model.PluginWebappPerf:
a.Metrics().ObservePluginWebappPerf(commonLabels["platform"], commonLabels["agent"], h.Labels["plugin_id"], h.Labels["plugin_metric_label"], h.Value)
default:
// we intentionally skip unknown metrics
}

View file

@ -134,6 +134,7 @@ type MetricsInterface interface {
ObserveMobileClientSessionMetadata(version string, platform string, value float64, notificationDisabled string)
ObserveDesktopCpuUsage(platform, version, process string, usage float64)
ObserveDesktopMemoryUsage(platform, version, process string, usage float64)
ObservePluginWebappPerf(platform, agent, pluginID, pluginMetricLabel string, elapsed float64)
ObserveAccessControlSearchQueryDuration(value float64)
ObserveAccessControlExpressionCompileDuration(value float64)

View file

@ -528,6 +528,11 @@ func (_m *MetricsInterface) ObservePluginMultiHookIterationDuration(pluginID str
_m.Called(pluginID, elapsed)
}
// ObservePluginWebappPerf provides a mock function with given fields: platform, agent, pluginID, pluginMetricLabel, elapsed
func (_m *MetricsInterface) ObservePluginWebappPerf(platform string, agent string, pluginID string, pluginMetricLabel string, elapsed float64) {
_m.Called(platform, agent, pluginID, pluginMetricLabel, elapsed)
}
// ObservePostsSearchDuration provides a mock function with given fields: elapsed
func (_m *MetricsInterface) ObservePostsSearchDuration(elapsed float64) {
_m.Called(elapsed)

View file

@ -235,6 +235,8 @@ type MetricsInterfaceImpl struct {
DesktopClientCPUUsage *prometheus.HistogramVec
DesktopClientMemoryUsage *prometheus.HistogramVec
PluginWebappPerf *prometheus.HistogramVec
AccessControlExpressionCompileDuration prometheus.Histogram
AccessControlEvaluateDuration prometheus.Histogram
AccessControlSearchQueryDuration prometheus.Histogram
@ -1369,6 +1371,18 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
)
m.Registry.MustRegister(m.ClientGlobalThreadsLoadDuration)
// Plugin webapp performance metrics
m.PluginWebappPerf = prometheus.NewHistogramVec(
withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemPlugin,
Name: "webapp_perf",
Help: "Plugin webapp performance measurements",
}),
[]string{"platform", "agent", "plugin_id", "plugin_metric_label"},
)
m.Registry.MustRegister(m.PluginWebappPerf)
m.MobileClientLoadDuration = prometheus.NewHistogramVec(
withLabels(prometheus.HistogramOpts{
Namespace: MetricsNamespace,
@ -2202,6 +2216,15 @@ func (mi *MetricsInterfaceImpl) ObserveGlobalThreadsLoadDuration(platform, agent
mi.ClientGlobalThreadsLoadDuration.With(prometheus.Labels{"platform": platform, "agent": agent, "user_id": effectiveUserID}).Observe(elapsed)
}
func (mi *MetricsInterfaceImpl) ObservePluginWebappPerf(platform, agent, pluginID, pluginMetricLabel string, elapsed float64) {
mi.PluginWebappPerf.With(prometheus.Labels{
"platform": platform,
"agent": agent,
"plugin_id": pluginID,
"plugin_metric_label": pluginMetricLabel,
}).Observe(elapsed)
}
func (mi *MetricsInterfaceImpl) ObserveDesktopCpuUsage(platform, version, process string, usage float64) {
mi.DesktopClientCPUUsage.With(prometheus.Labels{"platform": platform, "version": version, "processName": process}).Observe(usage)
}

View file

@ -44,6 +44,9 @@ const (
DesktopClientCPUUsage MetricType = "desktop_cpu"
DesktopClientMemoryUsage MetricType = "desktop_memory"
// PluginWebappPerf is the metric type for plugin webapp performance metrics
PluginWebappPerf MetricType = "plugin_webapp_perf"
performanceReportTTLMilliseconds = 300 * 1000 // 300 seconds/5 minutes
)