derp: add bytes dropped metric (#14698)
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, illumos) (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / crossmin (amd64, solaris) (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, illumos) (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / crossmin (amd64, solaris) (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Add bytes dropped counter metric by reason and kind. Fixes tailscale/corp#25918 Signed-off-by: Mike O'Driscoll <mikeo@tailscale.com>
This commit is contained in:
parent
6c30840cac
commit
6e3c746942
@ -357,6 +357,12 @@ type Conn interface {
|
||||
"counter",
|
||||
"DERP packets dropped by reason and by kind")
|
||||
|
||||
var bytesDropped = metrics.NewMultiLabelMap[dropReasonKindLabels](
|
||||
"derp_bytes_dropped",
|
||||
"counter",
|
||||
"DERP bytes dropped by reason and by kind",
|
||||
)
|
||||
|
||||
// NewServer returns a new DERP server. It doesn't listen on its own.
|
||||
// Connections are given to it via Server.Accept.
|
||||
func NewServer(privateKey key.NodePrivate, logf logger.Logf) *Server {
|
||||
@ -388,13 +394,13 @@ func NewServer(privateKey key.NodePrivate, logf logger.Logf) *Server {
|
||||
s.packetsRecvDisco = s.packetsRecvByKind.Get(string(packetKindDisco))
|
||||
s.packetsRecvOther = s.packetsRecvByKind.Get(string(packetKindOther))
|
||||
|
||||
genPacketsDroppedCounters()
|
||||
genDroppedCounters()
|
||||
|
||||
s.perClientSendQueueDepth = getPerClientSendQueueDepth()
|
||||
return s
|
||||
}
|
||||
|
||||
func genPacketsDroppedCounters() {
|
||||
func genDroppedCounters() {
|
||||
initMetrics := func(reason dropReason) {
|
||||
packetsDropped.Add(dropReasonKindLabels{
|
||||
Kind: string(packetKindDisco),
|
||||
@ -404,6 +410,14 @@ func genPacketsDroppedCounters() {
|
||||
Kind: string(packetKindOther),
|
||||
Reason: string(reason),
|
||||
}, 0)
|
||||
bytesDropped.Add(dropReasonKindLabels{
|
||||
Kind: string(packetKindDisco),
|
||||
Reason: string(reason),
|
||||
}, 0)
|
||||
bytesDropped.Add(dropReasonKindLabels{
|
||||
Kind: string(packetKindOther),
|
||||
Reason: string(reason),
|
||||
}, 0)
|
||||
}
|
||||
getMetrics := func(reason dropReason) []expvar.Var {
|
||||
return []expvar.Var{
|
||||
@ -415,6 +429,14 @@ func genPacketsDroppedCounters() {
|
||||
Kind: string(packetKindOther),
|
||||
Reason: string(reason),
|
||||
}),
|
||||
bytesDropped.Get(dropReasonKindLabels{
|
||||
Kind: string(packetKindDisco),
|
||||
Reason: string(reason),
|
||||
}),
|
||||
bytesDropped.Get(dropReasonKindLabels{
|
||||
Kind: string(packetKindOther),
|
||||
Reason: string(reason),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@ -431,12 +453,14 @@ func genPacketsDroppedCounters() {
|
||||
for _, dr := range dropReasons {
|
||||
initMetrics(dr)
|
||||
m := getMetrics(dr)
|
||||
if len(m) != 2 {
|
||||
if len(m) != 4 {
|
||||
panic("dropReason metrics out of sync")
|
||||
}
|
||||
|
||||
if m[0] == nil || m[1] == nil {
|
||||
panic("dropReason metrics out of sync")
|
||||
for _, v := range m {
|
||||
if v == nil {
|
||||
panic("dropReason metrics out of sync")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1207,6 +1231,7 @@ func (s *Server) recordDrop(packetBytes []byte, srcKey, dstKey key.NodePublic, r
|
||||
labels.Kind = string(packetKindOther)
|
||||
}
|
||||
packetsDropped.Add(labels, 1)
|
||||
bytesDropped.Add(labels, int64(len(packetBytes)))
|
||||
|
||||
if verboseDropKeys[dstKey] {
|
||||
// Preformat the log string prior to calling limitedLogf. The
|
||||
|
Loading…
Reference in New Issue
Block a user