|
|
@@ -744,11 +744,19 @@ func (conn *Conn) GetMetrics() common.LogFields {
|
|
|
logFields.Add(underlyingMetrics.GetMetrics())
|
|
|
}
|
|
|
|
|
|
- quicResumedSession := "0"
|
|
|
- if conn.connection.hasResumedSession() {
|
|
|
- quicResumedSession = "1"
|
|
|
+ metrics := conn.connection.connectionMetrics()
|
|
|
+
|
|
|
+ quicSentTicket := "0"
|
|
|
+ if metrics.tlsClientSentTicket {
|
|
|
+ quicSentTicket = "1"
|
|
|
+ }
|
|
|
+ logFields["quic_sent_ticket"] = quicSentTicket
|
|
|
+
|
|
|
+ quicDidResume := "0"
|
|
|
+ if metrics.tlsClientSentTicket {
|
|
|
+ quicDidResume = "1"
|
|
|
}
|
|
|
- logFields["quic_resumed_session"] = quicResumedSession
|
|
|
+ logFields["quic_did_resume"] = quicDidResume
|
|
|
|
|
|
return logFields
|
|
|
}
|
|
|
@@ -758,7 +766,8 @@ func (conn *Conn) GetMetrics() common.LogFields {
|
|
|
// CloseIdleConnections.
|
|
|
type QUICTransporter struct {
|
|
|
quicRoundTripper
|
|
|
- resumedSession atomic.Bool
|
|
|
+
|
|
|
+ quicConnectionMetrics atomic.Value
|
|
|
|
|
|
noticeEmitter func(string)
|
|
|
udpDialer func(ctx context.Context) (net.PacketConn, *net.UDPAddr, error)
|
|
|
@@ -854,7 +863,24 @@ func (t *QUICTransporter) closePacketConn() {
|
|
|
|
|
|
func (t *QUICTransporter) GetMetrics() common.LogFields {
|
|
|
logFields := make(common.LogFields)
|
|
|
- logFields["quic_resumed_session"] = t.resumedSession.Load()
|
|
|
+
|
|
|
+ metrics := t.quicConnectionMetrics.Load()
|
|
|
+ if m, ok := metrics.(*quicConnectionMetrics); ok {
|
|
|
+ quicSentTicket := "0"
|
|
|
+ if m.tlsClientSentTicket {
|
|
|
+ quicSentTicket = "1"
|
|
|
+ }
|
|
|
+ logFields["quic_sent_ticket"] = quicSentTicket
|
|
|
+
|
|
|
+ quicDidResume := "0"
|
|
|
+ if m.tlsClientSentTicket {
|
|
|
+ quicDidResume = "1"
|
|
|
+ }
|
|
|
+ logFields["quic_did_resume"] = quicDidResume
|
|
|
+ } else {
|
|
|
+ fmt.Printf("QUICTransporter.GetMetrics: unexpected quicConnectionMetrics type: %T\n", metrics)
|
|
|
+ }
|
|
|
+
|
|
|
return logFields
|
|
|
}
|
|
|
|
|
|
@@ -926,9 +952,8 @@ func (t *QUICTransporter) dialQUIC() (retConnection quicConnection, retErr error
|
|
|
return nil, errors.Trace(err)
|
|
|
}
|
|
|
|
|
|
- if connection.hasResumedSession() {
|
|
|
- t.resumedSession.Store(true)
|
|
|
- }
|
|
|
+ metrics := connection.connectionMetrics()
|
|
|
+ t.quicConnectionMetrics.Store(&metrics)
|
|
|
|
|
|
// dialQUIC uses quic-go.DialContext as we must create our own UDP sockets to
|
|
|
// set properties such as BIND_TO_DEVICE. However, when DialContext is used,
|
|
|
@@ -968,6 +993,13 @@ type quicListener interface {
|
|
|
Accept() (quicConnection, error)
|
|
|
}
|
|
|
|
|
|
+// quicConnectionMetircs provides metrics for a QUIC connection,
|
|
|
+// after a dial has been made.
|
|
|
+type quicConnectionMetrics struct {
|
|
|
+ tlsClientSentTicket bool
|
|
|
+ tlsDidResume bool
|
|
|
+}
|
|
|
+
|
|
|
type quicConnection interface {
|
|
|
io.Closer
|
|
|
LocalAddr() net.Addr
|
|
|
@@ -976,7 +1008,7 @@ type quicConnection interface {
|
|
|
OpenStream() (quicStream, error)
|
|
|
isErrorIndicatingClosed(err error) bool
|
|
|
isEarlyDataRejected(err error) bool
|
|
|
- hasResumedSession() bool
|
|
|
+ connectionMetrics() quicConnectionMetrics
|
|
|
}
|
|
|
|
|
|
type quicStream interface {
|
|
|
@@ -1016,10 +1048,7 @@ func (l *ietfQUICListener) Close() error {
|
|
|
|
|
|
type ietfQUICConnection struct {
|
|
|
ietf_quic.Connection
|
|
|
-
|
|
|
- // resumedSession is true if the TLS session was probably resumed.
|
|
|
- // This is only used by the clients to gather metrics.
|
|
|
- resumedSession bool
|
|
|
+ metrics quicConnectionMetrics
|
|
|
}
|
|
|
|
|
|
func (c *ietfQUICConnection) AcceptStream() (quicStream, error) {
|
|
|
@@ -1064,8 +1093,8 @@ func (c *ietfQUICConnection) isEarlyDataRejected(err error) bool {
|
|
|
return err == ietf_quic.Err0RTTRejected
|
|
|
}
|
|
|
|
|
|
-func (c *ietfQUICConnection) hasResumedSession() bool {
|
|
|
- return c.resumedSession
|
|
|
+func (c *ietfQUICConnection) connectionMetrics() quicConnectionMetrics {
|
|
|
+ return c.metrics
|
|
|
}
|
|
|
|
|
|
func dialQUIC(
|
|
|
@@ -1152,9 +1181,6 @@ func dialQUIC(
|
|
|
tlsClientSessionCache.Put("", ss)
|
|
|
}
|
|
|
|
|
|
- // Heuristic to determine if TLS dial is resuming a session.
|
|
|
- resumedSession := tlsClientSessionCache.IsSessionResumptionAvailable()
|
|
|
-
|
|
|
if dialEarly {
|
|
|
// Attempting 0-RTT if possible.
|
|
|
dialConnection, err = ietf_quic.DialEarly(
|
|
|
@@ -1176,9 +1202,14 @@ func dialQUIC(
|
|
|
return nil, errors.Trace(err)
|
|
|
}
|
|
|
|
|
|
+ metrics := quicConnectionMetrics{
|
|
|
+ tlsClientSentTicket: dialConnection.ConnectionState().TLS.DidResume,
|
|
|
+ tlsDidResume: dialConnection.TLSConnectionMetrics().ClientSentTicket,
|
|
|
+ }
|
|
|
+
|
|
|
return &ietfQUICConnection{
|
|
|
- Connection: dialConnection,
|
|
|
- resumedSession: resumedSession,
|
|
|
+ Connection: dialConnection,
|
|
|
+ metrics: metrics,
|
|
|
}, nil
|
|
|
|
|
|
} else {
|