wgengine/magicsock: add clientmetrics for TX bytes/packets by af & conn type (#17515)

Updates tailscale/corp#33206

Signed-off-by: Jordan Whited <jordan@tailscale.com>
pull/17395/merge
Jordan Whited 2 months ago committed by GitHub
parent 0a33aae823
commit af15ee9c5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -808,6 +808,16 @@ func registerMetrics(reg *usermetric.Registry) *metrics {
metricRecvDataBytesDERP.Register(&m.inboundBytesDERPTotal)
metricRecvDataBytesPeerRelayIPv4.Register(&m.inboundBytesPeerRelayIPv4Total)
metricRecvDataBytesPeerRelayIPv6.Register(&m.inboundBytesPeerRelayIPv6Total)
metricSendDataPacketsIPv4.Register(&m.outboundPacketsIPv4Total)
metricSendDataPacketsIPv6.Register(&m.outboundPacketsIPv6Total)
metricSendDataPacketsDERP.Register(&m.outboundPacketsDERPTotal)
metricSendDataPacketsPeerRelayIPv4.Register(&m.outboundPacketsPeerRelayIPv4Total)
metricSendDataPacketsPeerRelayIPv6.Register(&m.outboundPacketsPeerRelayIPv6Total)
metricSendDataBytesIPv4.Register(&m.outboundBytesIPv4Total)
metricSendDataBytesIPv6.Register(&m.outboundBytesIPv6Total)
metricSendDataBytesDERP.Register(&m.outboundBytesDERPTotal)
metricSendDataBytesPeerRelayIPv4.Register(&m.outboundBytesPeerRelayIPv4Total)
metricSendDataBytesPeerRelayIPv6.Register(&m.outboundBytesPeerRelayIPv6Total)
metricSendUDP.Register(&m.outboundPacketsIPv4Total)
metricSendUDP.Register(&m.outboundPacketsIPv6Total)
metricSendDERP.Register(&m.outboundPacketsDERPTotal)
@ -856,6 +866,16 @@ func deregisterMetrics() {
metricRecvDataBytesDERP.UnregisterAll()
metricRecvDataBytesPeerRelayIPv4.UnregisterAll()
metricRecvDataBytesPeerRelayIPv6.UnregisterAll()
metricSendDataPacketsIPv4.UnregisterAll()
metricSendDataPacketsIPv6.UnregisterAll()
metricSendDataPacketsDERP.UnregisterAll()
metricSendDataPacketsPeerRelayIPv4.UnregisterAll()
metricSendDataPacketsPeerRelayIPv6.UnregisterAll()
metricSendDataBytesIPv4.UnregisterAll()
metricSendDataBytesIPv6.UnregisterAll()
metricSendDataBytesDERP.UnregisterAll()
metricSendDataBytesPeerRelayIPv4.UnregisterAll()
metricSendDataBytesPeerRelayIPv6.UnregisterAll()
metricSendUDP.UnregisterAll()
metricSendDERP.UnregisterAll()
metricSendPeerRelay.UnregisterAll()
@ -3956,6 +3976,11 @@ var (
metricRecvDataPacketsIPv6 = clientmetric.NewAggregateCounter("magicsock_recv_data_ipv6")
metricRecvDataPacketsPeerRelayIPv4 = clientmetric.NewAggregateCounter("magicsock_recv_data_peer_relay_ipv4")
metricRecvDataPacketsPeerRelayIPv6 = clientmetric.NewAggregateCounter("magicsock_recv_data_peer_relay_ipv6")
metricSendDataPacketsDERP = clientmetric.NewAggregateCounter("magicsock_send_data_derp")
metricSendDataPacketsIPv4 = clientmetric.NewAggregateCounter("magicsock_send_data_ipv4")
metricSendDataPacketsIPv6 = clientmetric.NewAggregateCounter("magicsock_send_data_ipv6")
metricSendDataPacketsPeerRelayIPv4 = clientmetric.NewAggregateCounter("magicsock_send_data_peer_relay_ipv4")
metricSendDataPacketsPeerRelayIPv6 = clientmetric.NewAggregateCounter("magicsock_send_data_peer_relay_ipv6")
// Data bytes (non-disco)
metricRecvDataBytesDERP = clientmetric.NewAggregateCounter("magicsock_recv_data_bytes_derp")
@ -3963,6 +3988,11 @@ var (
metricRecvDataBytesIPv6 = clientmetric.NewAggregateCounter("magicsock_recv_data_bytes_ipv6")
metricRecvDataBytesPeerRelayIPv4 = clientmetric.NewAggregateCounter("magicsock_recv_data_bytes_peer_relay_ipv4")
metricRecvDataBytesPeerRelayIPv6 = clientmetric.NewAggregateCounter("magicsock_recv_data_bytes_peer_relay_ipv6")
metricSendDataBytesDERP = clientmetric.NewAggregateCounter("magicsock_send_data_bytes_derp")
metricSendDataBytesIPv4 = clientmetric.NewAggregateCounter("magicsock_send_data_bytes_ipv4")
metricSendDataBytesIPv6 = clientmetric.NewAggregateCounter("magicsock_send_data_bytes_ipv6")
metricSendDataBytesPeerRelayIPv4 = clientmetric.NewAggregateCounter("magicsock_send_data_bytes_peer_relay_ipv4")
metricSendDataBytesPeerRelayIPv6 = clientmetric.NewAggregateCounter("magicsock_send_data_bytes_peer_relay_ipv6")
// Disco packets
metricSendDiscoUDP = clientmetric.NewCounter("magicsock_disco_send_udp")

@ -1300,6 +1300,10 @@ func assertConnStatsAndUserMetricsEqual(t *testing.T, ms *magicStack) {
// the metrics by 2 to get the expected value.
// TODO(kradalby): https://github.com/tailscale/tailscale/issues/13420
c.Assert(metricSendUDP.Value(), qt.Equals, metricIPv4TxPackets*2)
c.Assert(metricSendDataPacketsIPv4.Value(), qt.Equals, metricIPv4TxPackets*2)
c.Assert(metricSendDataPacketsDERP.Value(), qt.Equals, metricDERPTxPackets*2)
c.Assert(metricSendDataBytesIPv4.Value(), qt.Equals, metricIPv4TxBytes*2)
c.Assert(metricSendDataBytesDERP.Value(), qt.Equals, metricDERPTxBytes*2)
c.Assert(metricRecvDataPacketsIPv4.Value(), qt.Equals, metricIPv4RxPackets*2)
c.Assert(metricRecvDataPacketsDERP.Value(), qt.Equals, metricDERPRxPackets*2)
c.Assert(metricRecvDataBytesIPv4.Value(), qt.Equals, metricIPv4RxBytes*2)

Loading…
Cancel
Save