mirror of https://github.com/prometheus/prometheus
discovery/consul: pass current context to Consul queries
Signed-off-by: Simon Pasquier <spasquie@redhat.com>pull/5230/head
parent
b41d6d54f2
commit
f9462d5d44
|
@ -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)
|
level.Debug(d.logger).Log("msg", "Watching services", "tag", d.watchedTag)
|
||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
srvs, meta, err := catalog.Services(&consul.QueryOptions{
|
opts := &consul.QueryOptions{
|
||||||
WaitIndex: *lastIndex,
|
WaitIndex: *lastIndex,
|
||||||
WaitTime: watchTimeout,
|
WaitTime: watchTimeout,
|
||||||
AllowStale: d.allowStale,
|
AllowStale: d.allowStale,
|
||||||
NodeMeta: d.watchedNodeMeta,
|
NodeMeta: d.watchedNodeMeta,
|
||||||
})
|
}
|
||||||
|
srvs, meta, err := catalog.Services(opts.WithContext(ctx))
|
||||||
elapsed := time.Since(t0)
|
elapsed := time.Since(t0)
|
||||||
rpcDuration.WithLabelValues("catalog", "services").Observe(elapsed.Seconds())
|
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)
|
level.Debug(srv.logger).Log("msg", "Watching service", "service", srv.name, "tag", srv.tag)
|
||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
nodes, meta, err := catalog.Service(srv.name, srv.tag, &consul.QueryOptions{
|
opts := &consul.QueryOptions{
|
||||||
WaitIndex: *lastIndex,
|
WaitIndex: *lastIndex,
|
||||||
WaitTime: watchTimeout,
|
WaitTime: watchTimeout,
|
||||||
AllowStale: srv.discovery.allowStale,
|
AllowStale: srv.discovery.allowStale,
|
||||||
NodeMeta: srv.discovery.watchedNodeMeta,
|
NodeMeta: srv.discovery.watchedNodeMeta,
|
||||||
})
|
}
|
||||||
|
nodes, meta, err := catalog.Service(srv.name, srv.tag, opts.WithContext(ctx))
|
||||||
elapsed := time.Since(t0)
|
elapsed := time.Since(t0)
|
||||||
rpcDuration.WithLabelValues("catalog", "service").Observe(elapsed.Seconds())
|
rpcDuration.WithLabelValues("catalog", "service").Observe(elapsed.Seconds())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue