Usage Stats: Make the UsageStatsService extension point more flexible (#34778) (#34895)

* Usage Stats: Rename service to use a more idiomatic name

* Usage Stats: Update MetricsFunc definition and implementations

* Revert "Usage Stats: Rename service to use a more idiomatic name"

This reverts commit 910ecce3e8.

* Usage Stats: Update MetricsFunc definition and implementations

(cherry picked from commit f601921670)
This commit is contained in:
Joan López de la Franca Beltran
2021-05-28 17:47:47 +02:00
committed by GitHub
parent 2ca76fa8ae
commit 6dc4e4d563
5 changed files with 61 additions and 71 deletions
@@ -39,14 +39,19 @@ func (ac *OSSAccessControlService) IsDisabled() bool {
}
func (ac *OSSAccessControlService) registerUsageMetrics() {
ac.UsageStats.RegisterMetric("stats.oss.accesscontrol.enabled.count", ac.getUsageMetrics)
ac.UsageStats.RegisterMetricsFunc(func() (map[string]interface{}, error) {
return map[string]interface{}{
"stats.oss.accesscontrol.enabled.count": ac.getUsageMetrics(),
}, nil
})
}
func (ac *OSSAccessControlService) getUsageMetrics() (interface{}, error) {
func (ac *OSSAccessControlService) getUsageMetrics() interface{} {
if ac.IsDisabled() {
return 0, nil
return 0
}
return 1, nil
return 1
}
// Evaluate evaluates access to the given resource