mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
discovery/consul: pass current context to Consul queries (#5230)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
commit
e60d314f43
|
@ -342,12 +342,13 @@ func (d *Discovery) watchServices(ctx context.Context, ch chan<- []*targetgroup.
|
|||
level.Debug(d.logger).Log("msg", "Watching services", "tag", d.watchedTag)
|
||||
|
||||
t0 := time.Now()
|
||||
srvs, meta, err := catalog.Services(&consul.QueryOptions{
|
||||
opts := &consul.QueryOptions{
|
||||
WaitIndex: *lastIndex,
|
||||
WaitTime: watchTimeout,
|
||||
AllowStale: d.allowStale,
|
||||
NodeMeta: d.watchedNodeMeta,
|
||||
})
|
||||
}
|
||||
srvs, meta, err := catalog.Services(opts.WithContext(ctx))
|
||||
elapsed := time.Since(t0)
|
||||
rpcDuration.WithLabelValues("catalog", "services").Observe(elapsed.Seconds())
|
||||
|
||||
|
@ -447,12 +448,13 @@ func (srv *consulService) watch(ctx context.Context, ch chan<- []*targetgroup.Gr
|
|||
level.Debug(srv.logger).Log("msg", "Watching service", "service", srv.name, "tag", srv.tag)
|
||||
|
||||
t0 := time.Now()
|
||||
nodes, meta, err := catalog.Service(srv.name, srv.tag, &consul.QueryOptions{
|
||||
opts := &consul.QueryOptions{
|
||||
WaitIndex: *lastIndex,
|
||||
WaitTime: watchTimeout,
|
||||
AllowStale: srv.discovery.allowStale,
|
||||
NodeMeta: srv.discovery.watchedNodeMeta,
|
||||
})
|
||||
}
|
||||
nodes, meta, err := catalog.Service(srv.name, srv.tag, opts.WithContext(ctx))
|
||||
elapsed := time.Since(t0)
|
||||
rpcDuration.WithLabelValues("catalog", "service").Observe(elapsed.Seconds())
|
||||
|
||||
|
|
Loading…
Reference in a new issue