Skip to content

Commit

Permalink
make the logging.Tracer and logging.ConnectionTracer a struct
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Sep 12, 2023
1 parent 7599f81 commit ad539d9
Show file tree
Hide file tree
Showing 46 changed files with 1,390 additions and 1,160 deletions.
4 changes: 2 additions & 2 deletions client.go
Expand Up @@ -34,7 +34,7 @@ type client struct {

conn quicConn

tracer logging.ConnectionTracer
tracer *logging.ConnectionTracer
tracingID uint64
logger utils.Logger
}
Expand Down Expand Up @@ -153,7 +153,7 @@ func dial(
if c.config.Tracer != nil {
c.tracer = c.config.Tracer(context.WithValue(ctx, ConnectionTracingKey, c.tracingID), protocol.PerspectiveClient, c.destConnID)
}
if c.tracer != nil {
if c.tracer != nil && c.tracer.StartedConnection != nil {
c.tracer.StartedConnection(c.sendConn.LocalAddr(), c.sendConn.RemoteAddr(), c.srcConnID, c.destConnID)
}
if err := c.dial(ctx); err != nil {
Expand Down
21 changes: 11 additions & 10 deletions client_test.go
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("Client", func() {
initialPacketNumber protocol.PacketNumber,
enable0RTT bool,
hasNegotiatedVersion bool,
tracer logging.ConnectionTracer,
tracer *logging.ConnectionTracer,
tracingID uint64,
logger utils.Logger,
v protocol.VersionNumber,
Expand All @@ -54,10 +54,11 @@ var _ = Describe("Client", func() {
tlsConf = &tls.Config{NextProtos: []string{"proto1"}}
connID = protocol.ParseConnectionID([]byte{0, 0, 0, 0, 0, 0, 0x13, 0x37})
originalClientConnConstructor = newClientConnection
tracer = mocklogging.NewMockConnectionTracer(mockCtrl)
var tr *logging.ConnectionTracer
tr, tracer = mocklogging.NewMockConnectionTracer(mockCtrl)
config = &Config{
Tracer: func(ctx context.Context, perspective logging.Perspective, id ConnectionID) logging.ConnectionTracer {
return tracer
Tracer: func(ctx context.Context, perspective logging.Perspective, id ConnectionID) *logging.ConnectionTracer {
return tr
},
Versions: []protocol.VersionNumber{protocol.Version1},
}
Expand All @@ -70,7 +71,7 @@ var _ = Describe("Client", func() {
destConnID: connID,
version: protocol.Version1,
sendConn: packetConn,
tracer: tracer,
tracer: tr,
logger: utils.DefaultLogger,
}
getMultiplexer() // make the sync.Once execute
Expand Down Expand Up @@ -121,7 +122,7 @@ var _ = Describe("Client", func() {
_ protocol.PacketNumber,
enable0RTT bool,
_ bool,
_ logging.ConnectionTracer,
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
_ protocol.VersionNumber,
Expand Down Expand Up @@ -158,7 +159,7 @@ var _ = Describe("Client", func() {
_ protocol.PacketNumber,
enable0RTT bool,
_ bool,
_ logging.ConnectionTracer,
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
_ protocol.VersionNumber,
Expand Down Expand Up @@ -195,7 +196,7 @@ var _ = Describe("Client", func() {
_ protocol.PacketNumber,
_ bool,
_ bool,
_ logging.ConnectionTracer,
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
_ protocol.VersionNumber,
Expand Down Expand Up @@ -280,7 +281,7 @@ var _ = Describe("Client", func() {
_ protocol.PacketNumber,
_ bool,
_ bool,
_ logging.ConnectionTracer,
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
versionP protocol.VersionNumber,
Expand Down Expand Up @@ -323,7 +324,7 @@ var _ = Describe("Client", func() {
pn protocol.PacketNumber,
_ bool,
hasNegotiatedVersion bool,
_ logging.ConnectionTracer,
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
versionP protocol.VersionNumber,
Expand Down
1 change: 0 additions & 1 deletion codecov.yml
Expand Up @@ -5,7 +5,6 @@ coverage:
- interop/
- internal/handshake/cipher_suite.go
- internal/utils/linkedlist/linkedlist.go
- logging/null_tracer.go
- fuzzing/
- metrics/
status:
Expand Down
2 changes: 1 addition & 1 deletion config_test.go
Expand Up @@ -125,7 +125,7 @@ var _ = Describe("Config", func() {
GetConfigForClient: func(info *ClientHelloInfo) (*Config, error) { return nil, errors.New("nope") },
AllowConnectionWindowIncrease: func(Connection, uint64) bool { calledAllowConnectionWindowIncrease = true; return true },
RequireAddressValidation: func(net.Addr) bool { calledAddrValidation = true; return true },
Tracer: func(context.Context, logging.Perspective, ConnectionID) logging.ConnectionTracer {
Tracer: func(context.Context, logging.Perspective, ConnectionID) *logging.ConnectionTracer {
calledTracer = true
return nil
},
Expand Down

0 comments on commit ad539d9

Please sign in to comment.