forked from quic-go/quic-go
implement qlogging of the parameters_restored event
This commit is contained in:
@@ -338,8 +338,9 @@ func (e eventKeyRetired) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
}
|
||||
|
||||
type eventTransportParameters struct {
|
||||
Owner owner
|
||||
SentBy protocol.Perspective
|
||||
Restore bool
|
||||
Owner owner
|
||||
SentBy protocol.Perspective
|
||||
|
||||
OriginalDestinationConnectionID protocol.ConnectionID
|
||||
InitialSourceConnectionID protocol.ConnectionID
|
||||
@@ -366,21 +367,28 @@ type eventTransportParameters struct {
|
||||
}
|
||||
|
||||
func (e eventTransportParameters) Category() category { return categoryTransport }
|
||||
func (e eventTransportParameters) Name() string { return "parameters_set" }
|
||||
func (e eventTransportParameters) IsNil() bool { return false }
|
||||
func (e eventTransportParameters) Name() string {
|
||||
if e.Restore {
|
||||
return "parameters_restored"
|
||||
}
|
||||
return "parameters_set"
|
||||
}
|
||||
func (e eventTransportParameters) IsNil() bool { return false }
|
||||
|
||||
func (e eventTransportParameters) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
enc.StringKey("owner", e.Owner.String())
|
||||
if e.SentBy == protocol.PerspectiveServer {
|
||||
enc.StringKey("original_destination_connection_id", connectionID(e.OriginalDestinationConnectionID).String())
|
||||
if e.StatelessResetToken != nil {
|
||||
enc.StringKey("stateless_reset_token", fmt.Sprintf("%x", e.StatelessResetToken[:]))
|
||||
}
|
||||
if e.RetrySourceConnectionID != nil {
|
||||
enc.StringKey("retry_source_connection_id", connectionID(*e.RetrySourceConnectionID).String())
|
||||
if !e.Restore {
|
||||
enc.StringKey("owner", e.Owner.String())
|
||||
if e.SentBy == protocol.PerspectiveServer {
|
||||
enc.StringKey("original_destination_connection_id", connectionID(e.OriginalDestinationConnectionID).String())
|
||||
if e.StatelessResetToken != nil {
|
||||
enc.StringKey("stateless_reset_token", fmt.Sprintf("%x", e.StatelessResetToken[:]))
|
||||
}
|
||||
if e.RetrySourceConnectionID != nil {
|
||||
enc.StringKey("retry_source_connection_id", connectionID(*e.RetrySourceConnectionID).String())
|
||||
}
|
||||
}
|
||||
enc.StringKey("initial_source_connection_id", connectionID(e.InitialSourceConnectionID).String())
|
||||
}
|
||||
enc.StringKey("initial_source_connection_id", connectionID(e.InitialSourceConnectionID).String())
|
||||
enc.BoolKey("disable_active_migration", e.DisableActiveMigration)
|
||||
enc.FloatKeyOmitEmpty("max_idle_timeout", milliseconds(e.MaxIdleTimeout))
|
||||
enc.Int64KeyNullEmpty("max_udp_payload_size", int64(e.MaxUDPPayloadSize))
|
||||
|
||||
28
qlog/qlog.go
28
qlog/qlog.go
@@ -169,14 +169,28 @@ func (t *connectionTracer) ReceivedTransportParameters(tp *wire.TransportParamet
|
||||
}
|
||||
|
||||
func (t *connectionTracer) RestoredTransportParameters(tp *wire.TransportParameters) {
|
||||
// TODO: implement
|
||||
ev := t.toTransportParameters(tp)
|
||||
ev.Restore = true
|
||||
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), ev)
|
||||
t.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (t *connectionTracer) recordTransportParameters(sentBy protocol.Perspective, tp *wire.TransportParameters) {
|
||||
owner := ownerLocal
|
||||
ev := t.toTransportParameters(tp)
|
||||
ev.Owner = ownerLocal
|
||||
if sentBy != t.perspective {
|
||||
owner = ownerRemote
|
||||
ev.Owner = ownerRemote
|
||||
}
|
||||
ev.SentBy = sentBy
|
||||
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), ev)
|
||||
t.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (t *connectionTracer) toTransportParameters(tp *wire.TransportParameters) *eventTransportParameters {
|
||||
var pa *preferredAddress
|
||||
if tp.PreferredAddress != nil {
|
||||
pa = &preferredAddress{
|
||||
@@ -188,10 +202,7 @@ func (t *connectionTracer) recordTransportParameters(sentBy protocol.Perspective
|
||||
StatelessResetToken: tp.PreferredAddress.StatelessResetToken,
|
||||
}
|
||||
}
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventTransportParameters{
|
||||
Owner: owner,
|
||||
SentBy: sentBy,
|
||||
return &eventTransportParameters{
|
||||
OriginalDestinationConnectionID: tp.OriginalDestinationConnectionID,
|
||||
InitialSourceConnectionID: tp.InitialSourceConnectionID,
|
||||
RetrySourceConnectionID: tp.RetrySourceConnectionID,
|
||||
@@ -210,8 +221,7 @@ func (t *connectionTracer) recordTransportParameters(sentBy protocol.Perspective
|
||||
InitialMaxStreamsUni: int64(tp.MaxUniStreamNum),
|
||||
PreferredAddress: pa,
|
||||
MaxDatagramFrameSize: tp.MaxDatagramFrameSize,
|
||||
})
|
||||
t.mutex.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
func (t *connectionTracer) SentPacket(hdr *wire.ExtendedHeader, packetSize logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
|
||||
|
||||
@@ -340,6 +340,30 @@ var _ = Describe("Tracing", func() {
|
||||
Expect(ev).ToNot(HaveKey("original_destination_connection_id"))
|
||||
})
|
||||
|
||||
It("records restored transport parameters", func() {
|
||||
tracer.RestoredTransportParameters(&logging.TransportParameters{
|
||||
InitialMaxStreamDataBidiLocal: 100,
|
||||
InitialMaxStreamDataBidiRemote: 200,
|
||||
InitialMaxStreamDataUni: 300,
|
||||
InitialMaxData: 400,
|
||||
MaxIdleTimeout: 123 * time.Millisecond,
|
||||
})
|
||||
entry := exportAndParseSingle()
|
||||
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||
Expect(entry.Name).To(Equal("transport:parameters_restored"))
|
||||
ev := entry.Event
|
||||
Expect(ev).ToNot(HaveKey("owner"))
|
||||
Expect(ev).ToNot(HaveKey("original_destination_connection_id"))
|
||||
Expect(ev).ToNot(HaveKey("stateless_reset_token"))
|
||||
Expect(ev).ToNot(HaveKey("retry_source_connection_id"))
|
||||
Expect(ev).ToNot(HaveKey("initial_source_connection_id"))
|
||||
Expect(ev).To(HaveKeyWithValue("max_idle_timeout", float64(123)))
|
||||
Expect(ev).To(HaveKeyWithValue("initial_max_data", float64(400)))
|
||||
Expect(ev).To(HaveKeyWithValue("initial_max_stream_data_bidi_local", float64(100)))
|
||||
Expect(ev).To(HaveKeyWithValue("initial_max_stream_data_bidi_remote", float64(200)))
|
||||
Expect(ev).To(HaveKeyWithValue("initial_max_stream_data_uni", float64(300)))
|
||||
})
|
||||
|
||||
It("records a sent packet, without an ACK", func() {
|
||||
tracer.SentPacket(
|
||||
&logging.ExtendedHeader{
|
||||
|
||||
Reference in New Issue
Block a user