QueryCaching: Use CachingServiceClient for query caching (#112128)
* Integrate mt querier with query caching * typo * let the caller set cache status response header * fix TestQueryAPI * make gen-go * handle CachingServiceClient being nil and make gen-go * include namespace in cache key * set signed in user namespace in query_test.go * fix test * remove commented out code * undo services/query/query.go changes * make gen-go * remove namespace requirement * fix tests * fix test * remove namespace from SignedInUser in tests * make gen-go
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package caching
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
QueryPubdash = "pubdash"
|
||||
QueryDashboard = "dashboard"
|
||||
)
|
||||
|
||||
var QueryCachingRequestHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: metrics.ExporterName,
|
||||
Subsystem: "caching",
|
||||
Name: "query_caching_request_duration_seconds",
|
||||
Help: "histogram of grafana query endpoint requests in seconds",
|
||||
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
||||
}, []string{"datasource_type", "cache", "query_type"})
|
||||
|
||||
var ShouldCacheQueryHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: metrics.ExporterName,
|
||||
Subsystem: "caching",
|
||||
Name: "should_cache_query_request_duration_seconds",
|
||||
Help: "histogram of grafana query endpoint requests in seconds",
|
||||
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
||||
}, []string{"datasource_type", "cache", "shouldCache", "query_type"})
|
||||
|
||||
var ResourceCachingRequestHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: metrics.ExporterName,
|
||||
Subsystem: "caching",
|
||||
Name: "resource_caching_request_duration_seconds",
|
||||
Help: "histogram of grafana resource endpoint requests in seconds",
|
||||
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
||||
}, []string{"plugin_id", "cache"})
|
||||
|
||||
func getQueryType(req *contextmodel.ReqContext) string {
|
||||
if req.IsPublicDashboardView() {
|
||||
return QueryPubdash
|
||||
}
|
||||
return QueryDashboard
|
||||
}
|
||||
Reference in New Issue
Block a user