[MM-63661] add access control metrics (#30680)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2025-05-11 22:11:42 +02:00
коммит произвёл GitHub
родитель 509b8e9af7
Коммит d452f4f043
3 изменённых файлов: 87 добавлений и 0 удалений

Просмотреть файл

@@ -134,4 +134,9 @@ type MetricsInterface interface {
ObserveMobileClientSessionMetadata(version string, platform string, value float64, notificationDisabled string) ObserveMobileClientSessionMetadata(version string, platform string, value float64, notificationDisabled string)
ObserveDesktopCpuUsage(platform, version, process string, usage float64) ObserveDesktopCpuUsage(platform, version, process string, usage float64)
ObserveDesktopMemoryUsage(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 return r0
} }
// IncrementAccessControlCacheInvalidation provides a mock function with given fields:
func (_m *MetricsInterface) IncrementAccessControlCacheInvalidation() {
_m.Called()
}
// IncrementChannelIndexCounter provides a mock function with given fields: // IncrementChannelIndexCounter provides a mock function with given fields:
func (_m *MetricsInterface) IncrementChannelIndexCounter() { func (_m *MetricsInterface) IncrementChannelIndexCounter() {
_m.Called() _m.Called()
@@ -303,6 +308,21 @@ func (_m *MetricsInterface) ObserveAPIEndpointDuration(endpoint string, method s
_m.Called(endpoint, method, statusCode, originClient, pageLoadContext, elapsed) _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 // 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) { func (_m *MetricsInterface) ObserveClientChannelSwitchDuration(platform string, agent string, fresh string, userID string, elapsed float64) {
_m.Called(platform, agent, fresh, userID, elapsed) _m.Called(platform, agent, fresh, userID, elapsed)

Просмотреть файл

@@ -45,6 +45,7 @@ const (
MetricsSubsystemClientsMobileApp = "mobileapp" MetricsSubsystemClientsMobileApp = "mobileapp"
MetricsSubsystemClientsWeb = "webapp" MetricsSubsystemClientsWeb = "webapp"
MetricsSubsystemClientsDesktopApp = "desktopapp" MetricsSubsystemClientsDesktopApp = "desktopapp"
MetricsSubsystemAccessControl = "access_control"
MetricsCloudInstallationLabel = "installationId" MetricsCloudInstallationLabel = "installationId"
MetricsCloudDatabaseClusterLabel = "databaseClusterName" MetricsCloudDatabaseClusterLabel = "databaseClusterName"
MetricsCloudInstallationGroupLabel = "installationGroupId" MetricsCloudInstallationGroupLabel = "installationGroupId"
@@ -234,6 +235,11 @@ type MetricsInterfaceImpl struct {
DesktopClientCPUUsage *prometheus.HistogramVec DesktopClientCPUUsage *prometheus.HistogramVec
DesktopClientMemoryUsage *prometheus.HistogramVec DesktopClientMemoryUsage *prometheus.HistogramVec
AccessControlEngineInitDuration prometheus.Histogram
AccessControlExpressionCompileDuration prometheus.Histogram
AccessControlEvaluateDuration prometheus.Histogram
AccessControlCacheInvalidation prometheus.Counter
} }
func init() { func init() {
@@ -1535,6 +1541,46 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
) )
m.Registry.MustRegister(m.DesktopClientMemoryUsage) 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 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) 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() { func (mi *MetricsInterfaceImpl) ClearMobileClientSessionMetadata() {
mi.MobileClientSessionMetadataGauge.Reset() mi.MobileClientSessionMetadataGauge.Reset()
} }