mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
[MM-63661] add access control metrics (#30680)
This commit is contained in:
parent
509b8e9af7
commit
d452f4f043
3 changed files with 87 additions and 0 deletions
|
|
@ -134,4 +134,9 @@ 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)
|
||||
|
||||
ObserveAccessControlEngineInitDuration(value float64)
|
||||
ObserveAccessControlExpressionCompileDuration(value float64)
|
||||
ObserveAccessControlEvaluateDuration(value float64)
|
||||
IncrementAccessControlCacheInvalidation()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ func (_m *MetricsInterface) GetLoggerMetricsCollector() logr.MetricsCollector {
|
|||
return r0
|
||||
}
|
||||
|
||||
// IncrementAccessControlCacheInvalidation provides a mock function with given fields:
|
||||
func (_m *MetricsInterface) IncrementAccessControlCacheInvalidation() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// IncrementChannelIndexCounter provides a mock function with given fields:
|
||||
func (_m *MetricsInterface) IncrementChannelIndexCounter() {
|
||||
_m.Called()
|
||||
|
|
@ -303,6 +308,21 @@ func (_m *MetricsInterface) ObserveAPIEndpointDuration(endpoint string, method s
|
|||
_m.Called(endpoint, method, statusCode, originClient, pageLoadContext, elapsed)
|
||||
}
|
||||
|
||||
// ObserveAccessControlEngineInitDuration provides a mock function with given fields: value
|
||||
func (_m *MetricsInterface) ObserveAccessControlEngineInitDuration(value float64) {
|
||||
_m.Called(value)
|
||||
}
|
||||
|
||||
// ObserveAccessControlEvaluateDuration provides a mock function with given fields: value
|
||||
func (_m *MetricsInterface) ObserveAccessControlEvaluateDuration(value float64) {
|
||||
_m.Called(value)
|
||||
}
|
||||
|
||||
// ObserveAccessControlExpressionCompileDuration provides a mock function with given fields: value
|
||||
func (_m *MetricsInterface) ObserveAccessControlExpressionCompileDuration(value float64) {
|
||||
_m.Called(value)
|
||||
}
|
||||
|
||||
// ObserveClientChannelSwitchDuration provides a mock function with given fields: platform, agent, fresh, userID, elapsed
|
||||
func (_m *MetricsInterface) ObserveClientChannelSwitchDuration(platform string, agent string, fresh string, userID string, elapsed float64) {
|
||||
_m.Called(platform, agent, fresh, userID, elapsed)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ const (
|
|||
MetricsSubsystemClientsMobileApp = "mobileapp"
|
||||
MetricsSubsystemClientsWeb = "webapp"
|
||||
MetricsSubsystemClientsDesktopApp = "desktopapp"
|
||||
MetricsSubsystemAccessControl = "access_control"
|
||||
MetricsCloudInstallationLabel = "installationId"
|
||||
MetricsCloudDatabaseClusterLabel = "databaseClusterName"
|
||||
MetricsCloudInstallationGroupLabel = "installationGroupId"
|
||||
|
|
@ -234,6 +235,11 @@ type MetricsInterfaceImpl struct {
|
|||
|
||||
DesktopClientCPUUsage *prometheus.HistogramVec
|
||||
DesktopClientMemoryUsage *prometheus.HistogramVec
|
||||
|
||||
AccessControlEngineInitDuration prometheus.Histogram
|
||||
AccessControlExpressionCompileDuration prometheus.Histogram
|
||||
AccessControlEvaluateDuration prometheus.Histogram
|
||||
AccessControlCacheInvalidation prometheus.Counter
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
@ -1535,6 +1541,46 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
|
|||
)
|
||||
m.Registry.MustRegister(m.DesktopClientMemoryUsage)
|
||||
|
||||
m.AccessControlEngineInitDuration = prometheus.NewHistogram(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemAccessControl,
|
||||
Name: "engine_init_duration_seconds",
|
||||
Help: "Duration of the time taken to initialize the access control engine (seconds)",
|
||||
ConstLabels: additionalLabels,
|
||||
})
|
||||
m.Registry.MustRegister(m.AccessControlEngineInitDuration)
|
||||
|
||||
m.AccessControlEvaluateDuration = prometheus.NewHistogram(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemAccessControl,
|
||||
Name: "evaluate_duration_seconds",
|
||||
Help: "Duration of the time taken to evaluate the access control engine (seconds)",
|
||||
ConstLabels: additionalLabels,
|
||||
})
|
||||
m.Registry.MustRegister(m.AccessControlEvaluateDuration)
|
||||
|
||||
m.AccessControlExpressionCompileDuration = prometheus.NewHistogram(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemAccessControl,
|
||||
Name: "expression_compile_duration_seconds",
|
||||
Help: "Duration of the time taken to compile the access control engine expression (seconds)",
|
||||
ConstLabels: additionalLabels,
|
||||
})
|
||||
m.Registry.MustRegister(m.AccessControlExpressionCompileDuration)
|
||||
|
||||
m.AccessControlCacheInvalidation = prometheus.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
Subsystem: MetricsSubsystemAccessControl,
|
||||
Name: "cache_invalidation_total",
|
||||
Help: "Total number of cache invalidations",
|
||||
ConstLabels: additionalLabels,
|
||||
})
|
||||
m.Registry.MustRegister(m.AccessControlCacheInvalidation)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
|
|
@ -2131,6 +2177,22 @@ func (mi *MetricsInterfaceImpl) ObserveMobileClientSessionMetadata(version, plat
|
|||
mi.MobileClientSessionMetadataGauge.With(prometheus.Labels{"version": version, "platform": platform, "notifications_disabled": notificationDisabled}).Set(value)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveAccessControlEngineInitDuration(value float64) {
|
||||
mi.AccessControlEngineInitDuration.Observe(value)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveAccessControlExpressionCompileDuration(value float64) {
|
||||
mi.AccessControlExpressionCompileDuration.Observe(value)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ObserveAccessControlEvaluateDuration(value float64) {
|
||||
mi.AccessControlEvaluateDuration.Observe(value)
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) IncrementAccessControlCacheInvalidation() {
|
||||
mi.AccessControlCacheInvalidation.Inc()
|
||||
}
|
||||
|
||||
func (mi *MetricsInterfaceImpl) ClearMobileClientSessionMetadata() {
|
||||
mi.MobileClientSessionMetadataGauge.Reset()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue