Add MFolderIDsServiceCount to count folderIDs in services pkg (#81237)

This commit is contained in:
idafurjes
2024-01-25 11:10:35 +01:00
committed by GitHub
parent 0d66ad68f8
commit 7e5544ab21
25 changed files with 129 additions and 3 deletions
+5 -1
View File
@@ -367,6 +367,7 @@ func getExistingDashboardByTitleAndFolder(sess *db.Session, dash *dashboards.Das
return isParentFolderChanged, dashboards.ErrDashboardFolderWithSameNameAsDashboard
}
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
// nolint:staticcheck
if !dash.IsFolder && (dash.FolderID != existing.FolderID || dash.ID == 0) {
isParentFolderChanged = true
@@ -818,6 +819,7 @@ func (d *dashboardStore) deleteAlertDefinition(dashboardId int64, sess *db.Sessi
func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.GetDashboardQuery) (*dashboards.Dashboard, error) {
var queryResult *dashboards.Dashboard
err := d.store.WithDbSession(ctx, func(sess *db.Session) error {
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
// nolint:staticcheck
if query.ID == 0 && len(query.UID) == 0 && (query.Title == nil || (query.FolderID == nil && query.FolderUID == "")) {
return dashboards.ErrDashboardIdentifierNotSet
@@ -837,6 +839,7 @@ func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.Get
// nolint:staticcheck
dashboard.FolderID = *query.FolderID
mustCols = append(mustCols, "folder_id")
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
}
has, err := sess.MustCols(mustCols...).Get(&dashboard)
@@ -940,7 +943,7 @@ func (d *dashboardStore) FindDashboards(ctx context.Context, query *dashboards.F
if len(query.Type) > 0 {
filters = append(filters, searchstore.TypeFilter{Dialect: d.store.GetDialect(), Type: query.Type})
}
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
// nolint:staticcheck
if len(query.FolderIds) > 0 {
filters = append(filters, searchstore.FolderFilter{IDs: query.FolderIds})
@@ -1013,6 +1016,7 @@ func (d *dashboardStore) CountDashboardsInFolder(
var count int64
var err error
err = d.store.WithDbSession(ctx, func(sess *db.Session) error {
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
// nolint:staticcheck
session := sess.In("folder_id", req.FolderID).In("org_id", req.OrgID).
In("is_folder", d.store.GetDialect().BooleanStr(false))