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,6 +5,7 @@ import (
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/auth/identity"
"github.com/grafana/grafana/pkg/services/dashboardimport"
@@ -83,6 +84,7 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
generatedDash.Del("__inputs")
generatedDash.Del("__requires")
metrics.MFolderIDsServiceCount.WithLabelValues("dashboardimport").Inc()
// here we need to get FolderId from FolderUID if it present in the request, if both exist, FolderUID would overwrite FolderID
if req.FolderUid != "" {
folder, err := s.folderService.Get(ctx, &folder.GetFolderQuery{
@@ -137,6 +139,7 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
return nil, err
}
metrics.MFolderIDsServiceCount.WithLabelValues("dashboardimport").Inc()
// nolint:staticcheck
err = s.libraryPanelService.ImportLibraryPanelsForDashboard(ctx, req.User, libraryElements, generatedDash.Get("panels").MustArray(), req.FolderId)
if err != nil {
@@ -149,6 +152,7 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
}
revision := savedDashboard.Data.Get("revision").MustInt64(0)
metrics.MFolderIDsServiceCount.WithLabelValues("dashboardimport").Inc()
return &dashboardimport.ImportDashboardResponse{
UID: savedDashboard.UID,
PluginId: req.PluginId,