Skip to content

Commit 0b62d45

Browse files
committed
TUN-8456: Update quic-go to 0.45 and collect mtu and congestion control metrics
1 parent cb6e599 commit 0b62d45

File tree

241 files changed

+27402
-19777
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+27402
-19777
lines changed

component-tests/test_tail.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ async def test_streaming_logs(self, tmp_path, component_tests_config):
4747
url = cfd_cli.get_management_wsurl("logs", config, config_path)
4848
async with connect(url, open_timeout=5, close_timeout=5) as websocket:
4949
# send start_streaming
50-
await websocket.send('{"type": "start_streaming"}')
50+
await websocket.send(json.dumps({
51+
"type": "start_streaming",
52+
"filters": {
53+
"events": ["http"]
54+
}
55+
}))
5156
# send some http requests to the tunnel to trigger some logs
5257
await generate_and_validate_http_events(websocket, config.get_url(), 10)
5358
# send stop_streaming
@@ -99,7 +104,8 @@ async def test_streaming_logs_sampling(self, tmp_path, component_tests_config):
99104
await websocket.send(json.dumps({
100105
"type": "start_streaming",
101106
"filters": {
102-
"sampling": 0.5
107+
"sampling": 0.5,
108+
"events": ["http"]
103109
}
104110
}))
105111
# don't expect any http logs

go.mod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ require (
2323
github.com/miekg/dns v1.1.50
2424
github.com/mitchellh/go-homedir v1.1.0
2525
github.com/pkg/errors v0.9.1
26-
github.com/prometheus/client_golang v1.13.0
27-
github.com/prometheus/client_model v0.2.0
28-
github.com/quic-go/quic-go v0.42.0
26+
github.com/prometheus/client_golang v1.19.1
27+
github.com/prometheus/client_model v0.5.0
28+
github.com/quic-go/quic-go v0.45.0
2929
github.com/rs/zerolog v1.20.0
3030
github.com/stretchr/testify v1.9.0
3131
github.com/urfave/cli/v2 v2.3.0
@@ -38,7 +38,7 @@ require (
3838
go.uber.org/automaxprocs v1.4.0
3939
golang.org/x/crypto v0.23.0
4040
golang.org/x/net v0.25.0
41-
golang.org/x/sync v0.6.0
41+
golang.org/x/sync v0.7.0
4242
golang.org/x/sys v0.20.0
4343
golang.org/x/term v0.20.0
4444
google.golang.org/protobuf v1.34.1
@@ -80,16 +80,16 @@ require (
8080
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
8181
github.com/opentracing/opentracing-go v1.2.0 // indirect
8282
github.com/pmezard/go-difflib v1.0.0 // indirect
83-
github.com/prometheus/common v0.37.0 // indirect
84-
github.com/prometheus/procfs v0.8.0 // indirect
83+
github.com/prometheus/common v0.48.0 // indirect
84+
github.com/prometheus/procfs v0.12.0 // indirect
8585
github.com/russross/blackfriday/v2 v2.1.0 // indirect
8686
go.opentelemetry.io/otel/metric v1.26.0 // indirect
8787
go.uber.org/mock v0.4.0 // indirect
88-
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
89-
golang.org/x/mod v0.11.0 // indirect
88+
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
89+
golang.org/x/mod v0.17.0 // indirect
9090
golang.org/x/oauth2 v0.17.0 // indirect
9191
golang.org/x/text v0.15.0 // indirect
92-
golang.org/x/tools v0.9.1 // indirect
92+
golang.org/x/tools v0.21.0 // indirect
9393
google.golang.org/appengine v1.6.8 // indirect
9494
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
9595
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect

go.sum

Lines changed: 18 additions & 414 deletions
Large diffs are not rendered by default.

quic/metrics.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ var (
3030
minRTT *prometheus.GaugeVec
3131
latestRTT *prometheus.GaugeVec
3232
smoothedRTT *prometheus.GaugeVec
33+
mtu *prometheus.GaugeVec
34+
congestionWindow *prometheus.GaugeVec
35+
congestionState *prometheus.GaugeVec
3336
}{
3437
totalConnections: prometheus.NewCounter(
3538
prometheus.CounterOpts{
@@ -146,6 +149,33 @@ var (
146149
},
147150
clientConnLabels,
148151
),
152+
mtu: prometheus.NewGaugeVec(
153+
prometheus.GaugeOpts{
154+
Namespace: namespace,
155+
Subsystem: "client",
156+
Name: "mtu",
157+
Help: "Current maximum transmission unit (MTU) of a connection",
158+
},
159+
clientConnLabels,
160+
),
161+
congestionWindow: prometheus.NewGaugeVec(
162+
prometheus.GaugeOpts{
163+
Namespace: namespace,
164+
Subsystem: "client",
165+
Name: "congestion_window",
166+
Help: "Current congestion window size",
167+
},
168+
clientConnLabels,
169+
),
170+
congestionState: prometheus.NewGaugeVec(
171+
prometheus.GaugeOpts{
172+
Namespace: namespace,
173+
Subsystem: "client",
174+
Name: "congestion_state",
175+
Help: "Current congestion control state. See https://pkg.go.dev/github.com/quic-go/[email protected]/logging#CongestionState for what each value maps to",
176+
},
177+
clientConnLabels,
178+
),
149179
}
150180

151181
registerClient = sync.Once{}
@@ -179,6 +209,9 @@ func newClientCollector(index string, logger *zerolog.Logger) *clientCollector {
179209
clientMetrics.minRTT,
180210
clientMetrics.latestRTT,
181211
clientMetrics.smoothedRTT,
212+
clientMetrics.mtu,
213+
clientMetrics.congestionWindow,
214+
clientMetrics.congestionState,
182215
packetTooBigDropped,
183216
)
184217
})
@@ -232,6 +265,19 @@ func (cc *clientCollector) updatedRTT(rtt *logging.RTTStats) {
232265
clientMetrics.smoothedRTT.WithLabelValues(cc.index).Set(durationToPromGauge(rtt.SmoothedRTT()))
233266
}
234267

268+
func (cc *clientCollector) updateCongestionWindow(size logging.ByteCount) {
269+
clientMetrics.congestionWindow.WithLabelValues(cc.index).Set(float64(size))
270+
}
271+
272+
func (cc *clientCollector) updatedCongestionState(state logging.CongestionState) {
273+
clientMetrics.congestionState.WithLabelValues(cc.index).Set(float64(state))
274+
}
275+
276+
func (cc *clientCollector) updateMTU(mtu logging.ByteCount) {
277+
clientMetrics.mtu.WithLabelValues(cc.index).Set(float64(mtu))
278+
cc.logger.Debug().Msgf("QUIC MTU updated to %d", mtu)
279+
}
280+
235281
func (cc *clientCollector) collectPackets(size logging.ByteCount, frames []logging.Frame, counter, bandwidth *prometheus.CounterVec, direction direction) {
236282
for _, frame := range frames {
237283
switch f := frame.(type) {

quic/tracing.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func newConnTracer(metricsCollector *clientCollector) *logging.ConnectionTracer
4747
DroppedPacket: tracer.DroppedPacket,
4848
UpdatedMetrics: tracer.UpdatedMetrics,
4949
LostPacket: tracer.LostPacket,
50+
UpdatedMTU: tracer.UpdatedMTU,
51+
UpdatedCongestionState: tracer.UpdatedCongestionState,
5052
}
5153
}
5254

@@ -76,6 +78,7 @@ func (ct *connTracer) LostPacket(level logging.EncryptionLevel, number logging.P
7678

7779
func (ct *connTracer) UpdatedMetrics(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int) {
7880
ct.metricsCollector.updatedRTT(rttStats)
81+
ct.metricsCollector.updateCongestionWindow(cwnd)
7982
}
8083

8184
func (ct *connTracer) SentLongHeaderPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, ecn logging.ECN, ack *logging.AckFrame, frames []logging.Frame) {
@@ -93,3 +96,11 @@ func (ct *connTracer) ReceivedLongHeaderPacket(hdr *logging.ExtendedHeader, size
9396
func (ct *connTracer) ReceivedShortHeaderPacket(hdr *logging.ShortHeader, size logging.ByteCount, ecn logging.ECN, frames []logging.Frame) {
9497
ct.metricsCollector.receivedPackets(size, frames)
9598
}
99+
100+
func (ct *connTracer) UpdatedMTU(mtu logging.ByteCount, done bool) {
101+
ct.metricsCollector.updateMTU(mtu)
102+
}
103+
104+
func (ct *connTracer) UpdatedCongestionState(state logging.CongestionState) {
105+
ct.metricsCollector.updatedCongestionState(state)
106+
}

supervisor/tunnel.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ func (e *EdgeTunnelServer) serveQUIC(
569569

570570
tlsConfig.CurvePreferences = curvePref
571571

572+
// quic-go 0.44 increases the initial packet size to 1280 by default. That breaks anyone running tunnel through WARP
573+
// because WARP MTU is 1280.
574+
var initialPacketSize uint16 = 1252
575+
if edgeAddr.IP.To4() == nil {
576+
initialPacketSize = 1232
577+
}
578+
572579
quicConfig := &quic.Config{
573580
HandshakeIdleTimeout: quicpogs.HandshakeIdleTimeout,
574581
MaxIdleTimeout: quicpogs.MaxIdleTimeout,
@@ -580,6 +587,7 @@ func (e *EdgeTunnelServer) serveQUIC(
580587
DisablePathMTUDiscovery: e.config.DisableQUICPathMTUDiscovery,
581588
MaxConnectionReceiveWindow: e.config.QUICConnectionLevelFlowControlLimit,
582589
MaxStreamReceiveWindow: e.config.QUICStreamLevelFlowControlLimit,
590+
InitialPacketSize: initialPacketSize,
583591
}
584592

585593
quicConn, err := connection.NewQUICConnection(

vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go

Lines changed: 0 additions & 64 deletions
This file was deleted.

vendor/github.com/prometheus/client_golang/prometheus/counter.go

Lines changed: 46 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)