Folders: Add metric for listing subfolders duration (#81144)

This commit is contained in:
Alexander Zobnin
2024-01-24 14:15:32 +01:00
committed by GitHub
parent 57ba8dc75d
commit 7872a128a2
2 changed files with 20 additions and 1 deletions
+9 -1
View File
@@ -9,10 +9,10 @@ import (
"sync"
"time"
"github.com/grafana/dskit/concurrency"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slices"
"github.com/grafana/dskit/concurrency"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/events"
"github.com/grafana/grafana/pkg/infra/db"
@@ -196,6 +196,14 @@ func (s *Service) Get(ctx context.Context, q *folder.GetFolderQuery) (*folder.Fo
}
func (s *Service) GetChildren(ctx context.Context, q *folder.GetChildrenQuery) ([]*folder.Folder, error) {
defer func(t time.Time) {
parent := q.UID
if q.UID != folder.SharedWithMeFolderUID {
parent = "folder"
}
s.metrics.foldersGetChildrenRequestsDuration.WithLabelValues(parent).Observe(time.Since(t).Seconds())
}(time.Now())
if q.SignedInUser == nil {
return nil, folder.ErrBadRequest.Errorf("missing signed in user")
}