make it possible to use a custom tracer and the default tracer in tests

This commit is contained in:
Marten Seemann 2021-02-15 13:58:59 +08:00
parent b94a4440cc
commit 7ee88def4a
2 changed files with 6 additions and 2 deletions

View file

@ -85,7 +85,7 @@ var _ = Describe("Key Update tests", func() {
sess, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
getTLSClientConfig(),
&quic.Config{Tracer: newTracer(func() logging.ConnectionTracer { return &keyUpdateConnTracer{} })},
getQuicConfig(&quic.Config{Tracer: newTracer(func() logging.ConnectionTracer { return &keyUpdateConnTracer{} })}),
)
Expect(err).ToNot(HaveOccurred())
str, err := sess.AcceptUniStream(context.Background())

View file

@ -272,7 +272,11 @@ func getQuicConfig(conf *quic.Config) *quic.Config {
} else {
conf = conf.Clone()
}
conf.Tracer = quicConfigTracer
if conf.Tracer == nil {
conf.Tracer = quicConfigTracer
} else if quicConfigTracer != nil {
conf.Tracer = logging.NewMultiplexedTracer(quicConfigTracer, conf.Tracer)
}
return conf
}