-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Custom Timeout for Queries #2474
Conversation
|
Generally contexts are per request. The timeout the query engine wraps the provided context with is merely a upper bound applied to guard against too-high user-defined timeouts. Whether this should be set in the query engine or rather the client boundary (e.g. API or rule evaluation code) is a different question :) For the introduction of custom timeouts though, this should not happen in the query engine itself but rather by the caller setting a timeout on the context passed to |
Did not know that before! Will make a lot of things easy! |
29dc6da
to
c6b329c
Compare
|
@fabxc Fixed it. But, I find sometimes that I am stuck here: https://github.com/prometheus/prometheus/blob/master/storage/local/storage.go#L547 for more than 10mins when running a heavy server. Just trying to understand why we are not cancelling and cleaning up midway. |
|
Yes, that code path should respect cancelation as well. Just nobody got around to making use of the cancelation signal throughout that bit of code yet. |
|
Code looks good in general. @brian-brazil final concerns on HTTP API extension? |
web/api/v1/api.go
Outdated
| @@ -345,6 +369,7 @@ func (api *API) dropSeries(r *http.Request) (interface{}, *apiError) { | |||
| return res, nil | |||
| } | |||
|
|
|||
| // Target has the information for 1 target. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 -> one
web/api/v1/api.go
Outdated
| @@ -386,10 +412,12 @@ func (api *API) targets(r *http.Request) (interface{}, *apiError) { | |||
| return res, nil | |||
| } | |||
|
|
|||
| // AlertmanagerDiscovery has all the active alert-managers | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Alertmanagers" is how we write it.
Sentence should end with period.
web/api/v1/api.go
Outdated
| type AlertmanagerDiscovery struct { | ||
| ActiveAlertmanagers []*AlertmanagerTarget `json:"activeAlertmanagers"` | ||
| } | ||
|
|
||
| // AlertmanagerTarget has info on 1 AM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 -> one, terminate with period.
|
Seems fine from an API standpoint. I've been considering having scrapes pass down their timeout via a header, and remote read could do the same, but I think those APIs will necessarily be different. |
|
Okay, this one seems good to go then. 👍 |
This is a WIP, tests are yet to be added. Just wanted to get feedback if this was the right approach.
Some tests I added were failing as a lot of time (>30secs) was being spent here: https://github.com/prometheus/prometheus/blob/master/storage/local/storage.go#L547 and context was ignored there. Any reason for ignoring context?
Closes #1399