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

View File

@@ -172,12 +172,13 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response
AnnotationsPermissions: annotationPermissions,
PublicDashboardEnabled: publicDashboardEnabled,
}
metrics.MFolderIDsAPICount.WithLabelValues(metrics.GetDashboard).Inc()
// lookup folder title
// nolint:staticcheck
if dash.FolderID > 0 {
// nolint:staticcheck
query := dashboards.GetDashboardQuery{ID: dash.FolderID, OrgID: c.SignedInUser.GetOrgID()}
metrics.MFolderIDsAPICount.WithLabelValues(metrics.GetDashboard).Inc()
queryResult, err := hs.DashboardService.GetDashboard(c.Req.Context(), &query)
if err != nil {
if errors.Is(err, dashboards.ErrFolderNotFound) {
@@ -974,6 +975,7 @@ func (hs *HTTPServer) RestoreDashboardVersion(c *contextmodel.ReqContext) respon
saveCmd.Message = fmt.Sprintf("Restored from version %d", version.Version)
// nolint:staticcheck
saveCmd.FolderID = dash.FolderID
metrics.MFolderIDsAPICount.WithLabelValues(metrics.RestoreDashboardVersion).Inc()
saveCmd.FolderUID = dash.FolderUID
return hs.postDashboard(c, saveCmd)