Add MFolderIDsAPICount metric to count FolderIDs in api package (#80866)

* Add MFolderIDsAPICount metric to cound FolderIDs in api package

* Change counter to counter vector with method names as string values
This commit is contained in:
idafurjes
2024-01-24 12:39:11 +01:00
committed by GitHub
parent 5576731332
commit 6b4eaa0d18
7 changed files with 42 additions and 3 deletions
+4 -1
View File
@@ -8,6 +8,7 @@ import (
"github.com/grafana/grafana/pkg/api/apierrors"
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/services/auth/identity"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/dashboards"
@@ -45,7 +46,7 @@ func (hs *HTTPServer) GetFolderPermissionList(c *contextmodel.ReqContext) respon
if perm.UserID > 0 && dtos.IsHiddenUser(perm.UserLogin, c.SignedInUser, hs.Cfg) {
continue
}
metrics.MFolderIDsAPICount.WithLabelValues(metrics.GetFolderPermissionList).Inc()
// nolint:staticcheck
perm.FolderID = folder.ID
perm.DashboardID = 0
@@ -103,6 +104,7 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *contextmodel.ReqContext) respon
Created: time.Now(),
Updated: time.Now(),
})
metrics.MFolderIDsAPICount.WithLabelValues(metrics.UpdateFolderPermissions).Inc()
}
acl, err := hs.getFolderACL(c.Req.Context(), c.SignedInUser, folder)
@@ -166,6 +168,7 @@ func (hs *HTTPServer) getFolderACL(ctx context.Context, user identity.Requester,
IsFolder: true,
Inherited: false,
})
metrics.MFolderIDsAPICount.WithLabelValues(metrics.GetFolderPermissionList).Inc()
}
return acl, nil