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:
+5
-1
@@ -9,6 +9,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/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
@@ -64,6 +65,7 @@ func (hs *HTTPServer) GetFolders(c *contextmodel.ReqContext) response.Response {
|
||||
Title: f.Title,
|
||||
ParentUID: f.ParentUID,
|
||||
})
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("GetFolders").Inc()
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusOK, hits)
|
||||
@@ -122,6 +124,7 @@ func (hs *HTTPServer) GetFolderByID(c *contextmodel.ReqContext) response.Respons
|
||||
if err != nil {
|
||||
return response.Error(http.StatusBadRequest, "id is invalid", err)
|
||||
}
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("GetFolderByID").Inc()
|
||||
// nolint:staticcheck
|
||||
folder, err := hs.folderService.Get(c.Req.Context(), &folder.GetFolderQuery{ID: &id, OrgID: c.SignedInUser.GetOrgID(), SignedInUser: c.SignedInUser})
|
||||
if err != nil {
|
||||
@@ -369,7 +372,7 @@ func (hs *HTTPServer) newToFolderDto(c *contextmodel.ReqContext, f *folder.Folde
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("newToFolderDto").Inc()
|
||||
return dtos.Folder{
|
||||
ID: f.ID, // nolint:staticcheck
|
||||
UID: f.UID,
|
||||
@@ -469,6 +472,7 @@ func (hs *HTTPServer) searchFolders(c *contextmodel.ReqContext) ([]dtos.FolderSe
|
||||
UID: hit.UID,
|
||||
Title: hit.Title,
|
||||
})
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("searchFolders").Inc()
|
||||
}
|
||||
|
||||
return folderHits, nil
|
||||
|
||||
Reference in New Issue
Block a user