mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
b4f46c31bb
Some checks failed
CI / windows (push) Has been cancelled
CI / vm (push) Has been cancelled
checklocks / checklocks (push) Successful in 1m0s
Dockerfile build / deploy (push) Successful in 3m53s
CI / race-root-integration (1/4) (push) Failing after 2m36s
CodeQL / Analyze (go) (push) Failing after 9m13s
CI / race-root-integration (2/4) (push) Successful in 2m33s
CI / race-root-integration (3/4) (push) Successful in 3m46s
CI / race-root-integration (4/4) (push) Failing after 3m43s
CI / test (-race, amd64, 1/3) (push) Failing after 18m39s
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Failing after 19m19s
CI / test (-race, amd64, 2/3) (push) Failing after 17m8s
CI / test (-race, amd64, 3/3) (push) Failing after 17m23s
CI / privileged (push) Failing after 30s
CI / race-build (push) Successful in 10m14s
CI / test (386) (push) Failing after 15m46s
CI / cross (386, linux) (push) Successful in 16m47s
CI / cross (amd64, darwin) (push) Successful in 16m50s
CI / cross (amd64, freebsd) (push) Successful in 16m45s
CI / cross (amd64, openbsd) (push) Successful in 16m44s
CI / cross (amd64, windows) (push) Successful in 16m18s
CI / cross (arm, 5, linux) (push) Successful in 16m34s
CI / cross (arm, 7, linux) (push) Successful in 16m27s
CI / cross (arm64, darwin) (push) Successful in 17m30s
CI / cross (arm64, linux) (push) Successful in 16m25s
CI / cross (arm64, windows) (push) Successful in 15m45s
CI / ios (push) Successful in 1m36s
CI / cross (loong64, linux) (push) Successful in 16m30s
CI / crossmin (amd64, plan9) (push) Successful in 10m38s
CI / android (push) Successful in 1m26s
CI / crossmin (ppc64, aix) (push) Successful in 10m43s
CI / tailscale_go (push) Successful in 45s
CI / fuzz (push) Has been skipped
CI / notify_slack (push) Has been cancelled
CI / check_mergeability (push) Has been cancelled
CI / depaware (push) Successful in 1m1s
CI / go_generate (push) Successful in 2m11s
CI / go_mod_tidy (push) Successful in 59s
CI / licenses (push) Successful in 9s
CI / staticcheck (386, windows) (push) Failing after 1m15s
CI / staticcheck (amd64, darwin) (push) Failing after 1m19s
CI / staticcheck (amd64, linux) (push) Failing after 1m19s
CI / staticcheck (amd64, windows) (push) Failing after 1m13s
CI / wasm (push) Successful in 27m59s
This required sharing the dropped packet metric between two packages (tstun and magicsock), so I've moved its definition to util/usermetric. Updates tailscale/corp#22075 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
70 lines
1.9 KiB
Go
70 lines
1.9 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"
|
|
|
|
// 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
|
|
}
|