package usermetric
import "tailscale.com/util/usermetric"
Package usermetric provides a container and handler for user-facing metrics.
Index ¶
- func NewMultiLabelMapWithRegistry[T comparable](m *Registry, name string, promType, helpText string) *metrics.MultiLabelMap[T]
- type DropLabels
- type DropReason
- type Gauge
- func (g *Gauge) Set(v float64)
- func (g *Gauge) String() string
- func (g *Gauge) WritePrometheus(w io.Writer, name string)
- type Metrics
- type Registry
- func (r *Registry) DroppedPacketsInbound() *metrics.MultiLabelMap[DropLabels]
- func (r *Registry) DroppedPacketsOutbound() *metrics.MultiLabelMap[DropLabels]
- func (r *Registry) Handler(w http.ResponseWriter, req *http.Request)
- func (r *Registry) MetricNames() []string
- func (r *Registry) NewGauge(name, help string) *Gauge
- func (r *Registry) String() string
Functions ¶
func NewMultiLabelMapWithRegistry ¶
func NewMultiLabelMapWithRegistry[T comparable](m *Registry, name string, promType, helpText string) *metrics.MultiLabelMap[T]
NewMultiLabelMapWithRegistry creates and register a new MultiLabelMap[T] variable with the given name and returns it. The variable is registered with the userfacing metrics package.
Note that usermetric are not protected against duplicate metrics name. It is the caller's responsibility to ensure that the name is unique.
Types ¶
type DropLabels ¶
type DropLabels struct { Reason DropReason }
DropLabels contains common label(s) for dropped packet counters.
type DropReason ¶
type DropReason string
DropReason is the reason why a packet was dropped.
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" )
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a gauge metric with no labels.
func (*Gauge) Set ¶
Set sets the gauge to the given value.
func (*Gauge) String ¶
String returns the string of the underlying expvar.Float. This satisfies the expvar.Var interface.
func (*Gauge) WritePrometheus ¶
WritePrometheus writes the gauge metric in Prometheus format to the given writer. This satisfies the varz.PrometheusWriter interface.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics contains user-facing metrics that are used by multiple packages.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry tracks user-facing metrics of various Tailscale subsystems.
func (*Registry) DroppedPacketsInbound ¶
func (r *Registry) DroppedPacketsInbound() *metrics.MultiLabelMap[DropLabels]
DroppedPacketsInbound returns the inbound dropped packet metric.
func (*Registry) DroppedPacketsOutbound ¶
func (r *Registry) DroppedPacketsOutbound() *metrics.MultiLabelMap[DropLabels]
DroppedPacketsOutbound returns the outbound dropped packet metric, creating it if necessary.
func (*Registry) Handler ¶
func (r *Registry) Handler(w http.ResponseWriter, req *http.Request)
Handler returns a varz.Handler that serves the userfacing expvar contained in this package.
func (*Registry) MetricNames ¶
Metrics returns the name of all the metrics in the registry.
func (*Registry) NewGauge ¶
NewGauge creates and register a new gauge metric with the given name and help text.
func (*Registry) String ¶
String returns the string representation of all the metrics and their values in the registry. It is useful for debugging.
Source Files ¶
metrics.go usermetric.go
- Version
- v1.84.1 (latest)
- Published
- May 29, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 11 hours ago –
Tools for package owners.