Clientv3 (retry) logs should use the configured logger.

clientv3 logs (especially tests) were poluted with unattributed to testing.T log lines:

```
{"level":"warn","ts":"2021-04-29T12:42:11.055+0200","logger":"etcd-client","caller":"v3/retry_interceptor.go:64","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc0000fafc0/#initially=[unix://localhost:m10]","attempt":0,"error":"rpc error: code = ResourceExhausted desc = etcdserver: mvcc: database space exceeded"}
```

The reasons were 2 fold:
  - Interceptors were copying logger before "WithLogger" could modify it.
  - We were not propagating the loggers in a few testing contexts.
This commit is contained in:
Piotr Tabor
2021-04-29 12:57:09 +02:00
parent ed4a87d541
commit bc8d3f6639
5 changed files with 14 additions and 11 deletions

View File

@@ -120,6 +120,7 @@ func epHealthCommandFunc(cmd *cobra.Command, args []string) {
hch <- epHealth{Ep: ep, Health: false, Error: err.Error()}
return
}
cli = cli.WithLogger(lg.Named("client"))
st := time.Now()
// get a random key. As long as we can get the response without an error, the
// endpoint is health.