mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -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
|
maxConcurrentQueries prometheus.Gauge
|
||||||
queryLogEnabled prometheus.Gauge
|
queryLogEnabled prometheus.Gauge
|
||||||
queryLogFailures prometheus.Counter
|
queryLogFailures prometheus.Counter
|
||||||
queryQueueTime prometheus.Summary
|
queryQueueTime prometheus.Observer
|
||||||
queryPrepareTime prometheus.Summary
|
queryPrepareTime prometheus.Observer
|
||||||
queryInnerEval prometheus.Summary
|
queryInnerEval prometheus.Observer
|
||||||
queryResultSort prometheus.Summary
|
queryResultSort prometheus.Observer
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertibleToInt64 returns true if v does not over-/underflow an int64.
|
// convertibleToInt64 returns true if v does not over-/underflow an int64.
|
||||||
|
@ -230,6 +230,16 @@ func NewEngine(opts EngineOpts) *Engine {
|
||||||
opts.Logger = log.NewNopLogger()
|
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{
|
metrics := &engineMetrics{
|
||||||
currentQueries: prometheus.NewGauge(prometheus.GaugeOpts{
|
currentQueries: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
@ -255,38 +265,10 @@ func NewEngine(opts EngineOpts) *Engine {
|
||||||
Name: "queries_concurrent_max",
|
Name: "queries_concurrent_max",
|
||||||
Help: "The max number of concurrent queries.",
|
Help: "The max number of concurrent queries.",
|
||||||
}),
|
}),
|
||||||
queryQueueTime: prometheus.NewSummary(prometheus.SummaryOpts{
|
queryQueueTime: queryResultSummary.WithLabelValues("queue_time"),
|
||||||
Namespace: namespace,
|
queryPrepareTime: queryResultSummary.WithLabelValues("prepare_time"),
|
||||||
Subsystem: subsystem,
|
queryInnerEval: queryResultSummary.WithLabelValues("inner_eval"),
|
||||||
Name: "query_duration_seconds",
|
queryResultSort: queryResultSummary.WithLabelValues("result_sort"),
|
||||||
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},
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if t := opts.ActiveQueryTracker; t != nil {
|
if t := opts.ActiveQueryTracker; t != nil {
|
||||||
|
@ -308,10 +290,7 @@ func NewEngine(opts EngineOpts) *Engine {
|
||||||
metrics.maxConcurrentQueries,
|
metrics.maxConcurrentQueries,
|
||||||
metrics.queryLogEnabled,
|
metrics.queryLogEnabled,
|
||||||
metrics.queryLogFailures,
|
metrics.queryLogFailures,
|
||||||
metrics.queryQueueTime,
|
queryResultSummary,
|
||||||
metrics.queryPrepareTime,
|
|
||||||
metrics.queryInnerEval,
|
|
||||||
metrics.queryResultSort,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue