Skip to content

Commit

Permalink
Merge pull request #2665 from lucas-clemente/logging-multiplexer
Browse files Browse the repository at this point in the history
add a multiplexer for the tracer
  • Loading branch information
marten-seemann authored Jul 11, 2020
2 parents 2f5cba0 + c8d4343 commit 50adf3a
Show file tree
Hide file tree
Showing 7 changed files with 755 additions and 3 deletions.
10 changes: 7 additions & 3 deletions logging/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ const (

// A Tracer traces events.
type Tracer interface {
// TracerForServer requests a new tracer for a connection that was accepted by the server.
// If nil is returned, tracing will be disabled for this connection.
TracerForServer(odcid ConnectionID) ConnectionTracer
// TracerForServer requests a new tracer for a connection that was dialed by the client.
// If nil is returned, tracing will be disabled for this connection.
TracerForClient(odcid ConnectionID) ConnectionTracer
}

Expand All @@ -89,13 +93,13 @@ type ConnectionTracer interface {
ClosedConnection(CloseReason)
SentTransportParameters(*TransportParameters)
ReceivedTransportParameters(*TransportParameters)
SentPacket(hdr *ExtendedHeader, packetSize ByteCount, ack *AckFrame, frames []Frame)
SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
ReceivedVersionNegotiationPacket(*Header, []VersionNumber)
ReceivedRetry(*Header)
ReceivedPacket(hdr *ExtendedHeader, packetSize ByteCount, frames []Frame)
ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame)
BufferedPacket(PacketType)
DroppedPacket(PacketType, ByteCount, PacketDropReason)
UpdatedMetrics(rttStats *RTTStats, cwnd ByteCount, bytesInFLight ByteCount, packetsInFlight int)
UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int)
LostPacket(EncryptionLevel, PacketNumber, PacketLossReason)
UpdatedPTOCount(value uint32)
UpdatedKeyFromTLS(EncryptionLevel, Perspective)
Expand Down
12 changes: 12 additions & 0 deletions logging/logging_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package logging
import (
"testing"

"github.com/golang/mock/gomock"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand All @@ -11,3 +13,13 @@ func TestLogging(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Logging Suite")
}

var mockCtrl *gomock.Controller

var _ = BeforeEach(func() {
mockCtrl = gomock.NewController(GinkgoT())
})

var _ = AfterEach(func() {
mockCtrl.Finish()
})
278 changes: 278 additions & 0 deletions logging/mock_connection_tracer_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions logging/mock_tracer_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions logging/mockgen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package logging

//go:generate sh -c "mockgen -package logging -destination mock_connection_tracer_test.go github.com/lucas-clemente/quic-go/logging ConnectionTracer"
//go:generate sh -c "mockgen -package logging -destination mock_tracer_test.go github.com/lucas-clemente/quic-go/logging Tracer"
Loading

0 comments on commit 50adf3a

Please sign in to comment.