
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
Updates #14280 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
86 lines
2.6 KiB
Go
86 lines
2.6 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// This file contains user-facing metrics that are used by multiple packages.
|
|
// Use it to define more common metrics. Any changes to the registry and
|
|
// metric types should be in usermetric.go.
|
|
|
|
package usermetric
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"tailscale.com/metrics"
|
|
)
|
|
|
|
// Metrics contains user-facing metrics that are used by multiple packages.
|
|
type Metrics struct {
|
|
initOnce sync.Once
|
|
|
|
droppedPacketsInbound *metrics.MultiLabelMap[DropLabels]
|
|
droppedPacketsOutbound *metrics.MultiLabelMap[DropLabels]
|
|
}
|
|
|
|
// DropReason is the reason why a packet was dropped.
|
|
type DropReason string
|
|
|
|
const (
|
|
// ReasonACL means that the packet was not permitted by ACL.
|
|
ReasonACL DropReason = "acl"
|
|
|
|
// ReasonMulticast means that the packet was dropped because it was a multicast packet.
|
|
ReasonMulticast DropReason = "multicast"
|
|
|
|
// ReasonLinkLocalUnicast means that the packet was dropped because it was a link-local unicast packet.
|
|
ReasonLinkLocalUnicast DropReason = "link_local_unicast"
|
|
|
|
// ReasonTooShort means that the packet was dropped because it was a bad packet,
|
|
// this could be due to a short packet.
|
|
ReasonTooShort DropReason = "too_short"
|
|
|
|
// ReasonFragment means that the packet was dropped because it was an IP fragment.
|
|
ReasonFragment DropReason = "fragment"
|
|
|
|
// ReasonUnknownProtocol means that the packet was dropped because it was an unknown protocol.
|
|
ReasonUnknownProtocol DropReason = "unknown_protocol"
|
|
|
|
// ReasonError means that the packet was dropped because of an error.
|
|
ReasonError DropReason = "error"
|
|
)
|
|
|
|
// DropLabels contains common label(s) for dropped packet counters.
|
|
type DropLabels struct {
|
|
Reason DropReason
|
|
}
|
|
|
|
// initOnce initializes the common metrics.
|
|
func (r *Registry) initOnce() {
|
|
r.m.initOnce.Do(func() {
|
|
r.m.droppedPacketsInbound = NewMultiLabelMapWithRegistry[DropLabels](
|
|
r,
|
|
"tailscaled_inbound_dropped_packets_total",
|
|
"counter",
|
|
"Counts the number of dropped packets received by the node from other peers",
|
|
)
|
|
r.m.droppedPacketsOutbound = NewMultiLabelMapWithRegistry[DropLabels](
|
|
r,
|
|
"tailscaled_outbound_dropped_packets_total",
|
|
"counter",
|
|
"Counts the number of packets dropped while being sent to other peers",
|
|
)
|
|
})
|
|
}
|
|
|
|
// DroppedPacketsOutbound returns the outbound dropped packet metric, creating it
|
|
// if necessary.
|
|
func (r *Registry) DroppedPacketsOutbound() *metrics.MultiLabelMap[DropLabels] {
|
|
r.initOnce()
|
|
return r.m.droppedPacketsOutbound
|
|
}
|
|
|
|
// DroppedPacketsInbound returns the inbound dropped packet metric.
|
|
func (r *Registry) DroppedPacketsInbound() *metrics.MultiLabelMap[DropLabels] {
|
|
r.initOnce()
|
|
return r.m.droppedPacketsInbound
|
|
}
|