mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
Folders: Add metric for listing subfolders duration (#81144)
This commit is contained in:
parent
57ba8dc75d
commit
7872a128a2
@ -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")
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ const (
|
||||
|
||||
type foldersMetrics struct {
|
||||
sharedWithMeFetchFoldersRequestsDuration *prometheus.HistogramVec
|
||||
foldersGetChildrenRequestsDuration *prometheus.HistogramVec
|
||||
}
|
||||
|
||||
func newFoldersMetrics(r prometheus.Registerer) *foldersMetrics {
|
||||
@ -26,5 +27,15 @@ func newFoldersMetrics(r prometheus.Registerer) *foldersMetrics {
|
||||
},
|
||||
[]string{"status"},
|
||||
),
|
||||
foldersGetChildrenRequestsDuration: promauto.With(r).NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "get_children_duration_seconds",
|
||||
Help: "Duration of listing subfolders in specific folder",
|
||||
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
||||
Namespace: metricsNamespace,
|
||||
Subsystem: metricsSubSystem,
|
||||
},
|
||||
[]string{"parent"},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user