mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
refactoring: make sure that query_duration_seconds metrics are the same (#7668)
* refactoring: make sure that query_duration_seconds are the same Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
00b7bdb1b6
commit
22acb87e09
|
@ -60,10 +60,10 @@ type engineMetrics struct {
|
|||
maxConcurrentQueries prometheus.Gauge
|
||||
queryLogEnabled prometheus.Gauge
|
||||
queryLogFailures prometheus.Counter
|
||||
queryQueueTime prometheus.Summary
|
||||
queryPrepareTime prometheus.Summary
|
||||
queryInnerEval prometheus.Summary
|
||||
queryResultSort prometheus.Summary
|
||||
queryQueueTime prometheus.Observer
|
||||
queryPrepareTime prometheus.Observer
|
||||
queryInnerEval prometheus.Observer
|
||||
queryResultSort prometheus.Observer
|
||||
}
|
||||
|
||||
// convertibleToInt64 returns true if v does not over-/underflow an int64.
|
||||
|
@ -230,6 +230,16 @@ func NewEngine(opts EngineOpts) *Engine {
|
|||
opts.Logger = log.NewNopLogger()
|
||||
}
|
||||
|
||||
queryResultSummary := prometheus.NewSummaryVec(prometheus.SummaryOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "query_duration_seconds",
|
||||
Help: "Query timings",
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
},
|
||||
[]string{"slice"},
|
||||
)
|
||||
|
||||
metrics := &engineMetrics{
|
||||
currentQueries: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
|
@ -255,38 +265,10 @@ func NewEngine(opts EngineOpts) *Engine {
|
|||
Name: "queries_concurrent_max",
|
||||
Help: "The max number of concurrent queries.",
|
||||
}),
|
||||
queryQueueTime: prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "query_duration_seconds",
|
||||
Help: "Query timings",
|
||||
ConstLabels: prometheus.Labels{"slice": "queue_time"},
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
}),
|
||||
queryPrepareTime: prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "query_duration_seconds",
|
||||
Help: "Query timings",
|
||||
ConstLabels: prometheus.Labels{"slice": "prepare_time"},
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
}),
|
||||
queryInnerEval: prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "query_duration_seconds",
|
||||
Help: "Query timings",
|
||||
ConstLabels: prometheus.Labels{"slice": "inner_eval"},
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
}),
|
||||
queryResultSort: prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "query_duration_seconds",
|
||||
Help: "Query timings",
|
||||
ConstLabels: prometheus.Labels{"slice": "result_sort"},
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
}),
|
||||
queryQueueTime: queryResultSummary.WithLabelValues("queue_time"),
|
||||
queryPrepareTime: queryResultSummary.WithLabelValues("prepare_time"),
|
||||
queryInnerEval: queryResultSummary.WithLabelValues("inner_eval"),
|
||||
queryResultSort: queryResultSummary.WithLabelValues("result_sort"),
|
||||
}
|
||||
|
||||
if t := opts.ActiveQueryTracker; t != nil {
|
||||
|
@ -308,10 +290,7 @@ func NewEngine(opts EngineOpts) *Engine {
|
|||
metrics.maxConcurrentQueries,
|
||||
metrics.queryLogEnabled,
|
||||
metrics.queryLogFailures,
|
||||
metrics.queryQueueTime,
|
||||
metrics.queryPrepareTime,
|
||||
metrics.queryInnerEval,
|
||||
metrics.queryResultSort,
|
||||
queryResultSummary,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue