Access Control: Add histograms for evaluator and permissions checks (#34026)
This patch adds metrics to support instrumenting the accesscontrols package. It also instruments the accesscontrol evaluator and the permissions function. Co-authored-by: Vardan Torosyan <vardants@gmail.com>
This commit is contained in:
co-authored by
Vardan Torosyan
parent
25d42dbedb
commit
fc451cf277
@@ -4,10 +4,12 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/evaluator"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// OSSAccessControlService is the service implementing role based access control.
|
||||
@@ -39,6 +41,9 @@ func (ac *OSSAccessControlService) Evaluate(ctx context.Context, user *models.Si
|
||||
|
||||
// GetUserPermissions returns user permissions based on built-in roles
|
||||
func (ac *OSSAccessControlService) GetUserPermissions(ctx context.Context, user *models.SignedInUser) ([]*accesscontrol.Permission, error) {
|
||||
timer := prometheus.NewTimer(metrics.MAccessPermissionsSummary)
|
||||
defer timer.ObserveDuration()
|
||||
|
||||
builtinRoles := ac.GetUserBuiltInRoles(user)
|
||||
permissions := make([]*accesscontrol.Permission, 0)
|
||||
for _, builtin := range builtinRoles {
|
||||
|
||||
Reference in New Issue
Block a user