adjust metrics buckets

This commit is contained in:
Alexander Zobnin
2024-09-09 15:08:32 +02:00
parent 43eb92c395
commit b1eacabc61
2 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -10,6 +10,8 @@ const (
metricsSubSystem = "dashboards" metricsSubSystem = "dashboards"
) )
var defaultBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25}
type dashboardsMetrics struct { type dashboardsMetrics struct {
sharedWithMeFetchDashboardsRequestsDuration *prometheus.HistogramVec sharedWithMeFetchDashboardsRequestsDuration *prometheus.HistogramVec
searchRequestsDuration *prometheus.HistogramVec searchRequestsDuration *prometheus.HistogramVec
@@ -21,7 +23,7 @@ func newDashboardsMetrics(r prometheus.Registerer) *dashboardsMetrics {
prometheus.HistogramOpts{ prometheus.HistogramOpts{
Name: "sharedwithme_fetch_dashboards_duration_seconds", Name: "sharedwithme_fetch_dashboards_duration_seconds",
Help: "Duration of fetching dashboards with permissions directly assigned to user", Help: "Duration of fetching dashboards with permissions directly assigned to user",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100}, Buckets: defaultBuckets,
Namespace: metricsNamespace, Namespace: metricsNamespace,
Subsystem: metricsSubSystem, Subsystem: metricsSubSystem,
}, },
@@ -31,7 +33,7 @@ func newDashboardsMetrics(r prometheus.Registerer) *dashboardsMetrics {
prometheus.HistogramOpts{ prometheus.HistogramOpts{
Name: "search_dashboards_duration_seconds", Name: "search_dashboards_duration_seconds",
Help: "Duration of dashboards search (by authorization engine)", Help: "Duration of dashboards search (by authorization engine)",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100}, Buckets: defaultBuckets,
Namespace: metricsNamespace, Namespace: metricsNamespace,
Subsystem: metricsSubSystem, Subsystem: metricsSubSystem,
}, },
+2 -2
View File
@@ -47,8 +47,8 @@ func (dr *DashboardServiceImpl) findDashboardsZanzanaCompare(ctx context.Context
go func() { go func() {
timer := prometheus.NewTimer(dr.metrics.searchRequestsDuration.WithLabelValues("zanzana")) timer := prometheus.NewTimer(dr.metrics.searchRequestsDuration.WithLabelValues("zanzana"))
start := time.Now()
defer timer.ObserveDuration() defer timer.ObserveDuration()
start := time.Now()
queryZanzana := *query queryZanzana := *query
res, err := dr.findDashboardsZanzana(ctx, &queryZanzana) res, err := dr.findDashboardsZanzana(ctx, &queryZanzana)
@@ -57,8 +57,8 @@ func (dr *DashboardServiceImpl) findDashboardsZanzanaCompare(ctx context.Context
go func() { go func() {
timer := prometheus.NewTimer(dr.metrics.searchRequestsDuration.WithLabelValues("grafana")) timer := prometheus.NewTimer(dr.metrics.searchRequestsDuration.WithLabelValues("grafana"))
start := time.Now()
defer timer.ObserveDuration() defer timer.ObserveDuration()
start := time.Now()
res, err := dr.FindDashboards(ctx, query) res, err := dr.FindDashboards(ctx, query)
result <- searchResult{"grafana", res, err, time.Since(start)} result <- searchResult{"grafana", res, err, time.Since(start)}