Extract timeout from context in Prom client

For vector and range queries, the Prometheus HTTP API takes a timeout
parameter.  Previously, we ignored this parameter.  Now, we check to see
if the context passed to the query contains a deadline, and if so,
compare that to the current time to calculate an appropriate timeout for
query evaulation.
This commit is contained in:
Solly Ross 2017-06-27 19:55:45 -04:00
parent d1d60f7f5e
commit 01755d5acb
2 changed files with 20 additions and 5 deletions

View file

@ -40,7 +40,9 @@ type Range struct {
Step time.Duration
}
// TODO: support timeout in the client?
// Client is a Prometheus client for the Prometheus HTTP API.
// The "timeout" parameter for the HTTP API is set based on the context's deadline,
// when present and applicable.
type Client interface {
// Series lists the time series matching the given series selectors
Series(ctx context.Context, interval model.Interval, selectors ...Selector) ([]Series, error)