usermetric: add initial user-facing metrics
This commit adds a new usermetric package and wires up metrics across the tailscale client. Updates tailscale/corp#22075 Co-authored-by: Anton Tolchanov <anton@tailscale.com> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
committed by
Kristoffer Dalby
parent
06c31f4e91
commit
a2c42d3cd4
@@ -315,6 +315,12 @@ func mustHexDecode(s string) []byte {
|
||||
}
|
||||
|
||||
func TestFilter(t *testing.T) {
|
||||
// Reset the metrics before test. These are global
|
||||
// so the different tests might have affected them.
|
||||
metricInboundDroppedPacketsTotal.SetInt(dropPacketLabel{Reason: DropReasonACL}, 0)
|
||||
metricInboundDroppedPacketsTotal.SetInt(dropPacketLabel{Reason: DropReasonError}, 0)
|
||||
metricOutboundDroppedPacketsTotal.SetInt(dropPacketLabel{Reason: DropReasonACL}, 0)
|
||||
|
||||
chtun, tun := newChannelTUN(t.Logf, true)
|
||||
defer tun.Close()
|
||||
|
||||
@@ -429,6 +435,22 @@ func TestFilter(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
inACL := metricInboundDroppedPacketsTotal.Get(dropPacketLabel{Reason: DropReasonACL})
|
||||
inError := metricInboundDroppedPacketsTotal.Get(dropPacketLabel{Reason: DropReasonError})
|
||||
outACL := metricOutboundDroppedPacketsTotal.Get(dropPacketLabel{Reason: DropReasonACL})
|
||||
|
||||
assertMetricPackets(t, "inACL", "3", inACL.String())
|
||||
assertMetricPackets(t, "inError", "0", inError.String())
|
||||
assertMetricPackets(t, "outACL", "1", outACL.String())
|
||||
|
||||
}
|
||||
|
||||
func assertMetricPackets(t *testing.T, metricName, want, got string) {
|
||||
t.Helper()
|
||||
if want != got {
|
||||
t.Errorf("%s got unexpected value, got %s, want %s", metricName, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllocs(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user