Skip to content

Commit

Permalink
Track duration for all querier even if they fail
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkoyun committed Aug 15, 2019
1 parent 6886dbe commit 87e215d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/query/api/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ func (api *API) query(r *http.Request) (interface{}, []error, *ApiError) {
defer span.Finish()

begin := api.now()
defer api.instantQueryDuration.Observe(time.Since(begin).Seconds())

qry, err := api.queryEngine.NewInstantQuery(api.queryableCreate(enableDedup, 0, enablePartialResponse), r.FormValue("query"), ts)
if err != nil {
return nil, nil, &ApiError{errorBadData, err}
Expand All @@ -329,7 +331,6 @@ func (api *API) query(r *http.Request) (interface{}, []error, *ApiError) {
return nil, nil, &ApiError{errorExec, res.Err}
}
api.instantQueries.Inc()
api.instantQueryDuration.Observe(time.Since(begin).Seconds())

return &queryData{
ResultType: res.Value.Type(),
Expand Down Expand Up @@ -400,6 +401,8 @@ func (api *API) queryRange(r *http.Request) (interface{}, []error, *ApiError) {
defer span.Finish()

begin := api.now()
defer api.rangeQueryDuration.Observe(time.Since(begin).Seconds())

qry, err := api.queryEngine.NewRangeQuery(
api.queryableCreate(enableDedup, maxSourceResolution, enablePartialResponse),
r.FormValue("query"),
Expand All @@ -423,7 +426,6 @@ func (api *API) queryRange(r *http.Request) (interface{}, []error, *ApiError) {
return nil, nil, &ApiError{errorExec, res.Err}
}
api.rangeQueries.Inc()
api.rangeQueryDuration.Observe(time.Since(begin).Seconds())

return &queryData{
ResultType: res.Value.Type(),
Expand Down

0 comments on commit 87e215d

Please sign in to comment.