Skip to content

Commit

Permalink
add queue_time slice to query_duration_seconds (prometheus#4050)
Browse files Browse the repository at this point in the history
  • Loading branch information
roganartu authored and brian-brazil committed Apr 5, 2018
1 parent fe10b36 commit 7cd56f5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions promql/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
type engineMetrics struct {
currentQueries prometheus.Gauge
maxConcurrentQueries prometheus.Gauge
queryQueueTime prometheus.Summary
queryPrepareTime prometheus.Summary
queryInnerEval prometheus.Summary
queryResultAppend prometheus.Summary
Expand Down Expand Up @@ -177,6 +178,13 @@ func NewEngine(logger log.Logger, reg prometheus.Registerer, maxConcurrent int,
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"},
}),
queryPrepareTime: prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Expand Down Expand Up @@ -308,6 +316,7 @@ func (ng *Engine) exec(ctx context.Context, q *query) (Value, error) {
defer ng.gate.Done()

queueTimer.Stop()
ng.metrics.queryQueueTime.Observe(queueTimer.ElapsedTime().Seconds())

// Cancel when execution is done or an error was raised.
defer q.cancel()
Expand Down

0 comments on commit 7cd56f5

Please sign in to comment.