usermetric

package
v1.78.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package usermetric provides a container and handler for user-facing metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMultiLabelMapWithRegistry added in v1.76.0

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 added in v1.78.0

type DropLabels struct {
	Reason DropReason
}

DropLabels contains common label(s) for dropped packet counters.

type DropReason added in v1.78.0

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"

	// 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

func (g *Gauge) Set(v float64)

Set sets the gauge to the given value.

func (*Gauge) String

func (g *Gauge) String() string

String returns the string of the underlying expvar.Float. This satisfies the expvar.Var interface.

func (*Gauge) WritePrometheus

func (g *Gauge) WritePrometheus(w io.Writer, name string)

WritePrometheus writes the gauge metric in Prometheus format to the given writer. This satisfies the varz.PrometheusWriter interface.

type Metrics added in v1.78.0

type Metrics struct {
	// contains filtered or unexported fields
}

Metrics contains user-facing metrics that are used by multiple packages.

type Registry added in v1.76.0

type Registry struct {
	// contains filtered or unexported fields
}

Registry tracks user-facing metrics of various Tailscale subsystems.

func (*Registry) DroppedPacketsInbound added in v1.78.0

func (r *Registry) DroppedPacketsInbound() *metrics.MultiLabelMap[DropLabels]

DroppedPacketsInbound returns the inbound dropped packet metric.

func (*Registry) DroppedPacketsOutbound added in v1.78.0

func (r *Registry) DroppedPacketsOutbound() *metrics.MultiLabelMap[DropLabels]

DroppedPacketsOutbound returns the outbound dropped packet metric, creating it if necessary.

func (*Registry) Handler added in v1.76.0

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 added in v1.78.0

func (r *Registry) MetricNames() []string

Metrics returns the name of all the metrics in the registry.

func (*Registry) NewGauge added in v1.76.0

func (r *Registry) NewGauge(name, help string) *Gauge

NewGauge creates and register a new gauge metric with the given name and help text.

func (*Registry) String added in v1.76.0

func (r *Registry) String() string

String returns the string representation of all the metrics and their values in the registry. It is useful for debugging.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL