Movatterモバイル変換


[0]ホーム

URL:


clientmetric

package
v1.92.3Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License:BSD-3-ClauseImports:13Imported by:64

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package clientmetric provides client-side metrics whose valuesget occasionally logged.

Index

Constants

This section is empty.

Variables

View Source
var TestHooks testHooks

Functions

funcEncodeLogTailMetricsDelta

func EncodeLogTailMetricsDelta()string

EncodeLogTailMetricsDelta return an encoded string representing the metricsdifferences since the previous call.

It implements the requirements of a logtail.Config.MetricsDeltafunc. Notably, its output is safe to embed in a JSON string literalwithout further escaping.

The current encoding is:

  • name immediately following metric:'N' + hex(varint(len(name))) + name
  • set value of a metric:'S' + hex(varint(wireid)) + hex(varint(value))
  • increment a metric: (decrements if negative)'I' + hex(varint(wireid)) + hex(varint(value))

funcHasPublishedadded inv1.28.0

func HasPublished(namestring)bool

HasPublished reports whether a metric with the given name has already beenpublished.

funcWritePrometheusExpositionFormat

func WritePrometheusExpositionFormat(wio.Writer)

WritePrometheusExpositionFormat writes all client metrics to w inthe Prometheus text-based exposition format.

Seehttps://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md

Types

typeAggregateCounteradded inv1.78.0

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

AggregateCounter returns a sum of expvar counters registered with it.

funcNewAggregateCounteradded inv1.78.0

func NewAggregateCounter(namestring) *AggregateCounter

NewAggregateCounter returns a new aggregate counter that returnsa sum of expvar variables registered with it.

func (*AggregateCounter)Registeradded inv1.78.0

func (c *AggregateCounter) Register(counter *expvar.Int)

Register registers provided expvar counter.When a counter is added to the counter, it will be resetto start counting from 0. This is to avoid incrementing thecounter with an unexpectedly large value.

func (*AggregateCounter)UnregisterAlladded inv1.78.0

func (c *AggregateCounter) UnregisterAll()

UnregisterAll unregisters all counters resulting in itstarting back down at zero. This is to ensure monotonicityand respect the semantics of the counter.

func (*AggregateCounter)Valueadded inv1.78.0

func (c *AggregateCounter) Value()int64

typeMetric

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

Metric is an integer metric value that's tracked over time.

It's safe for concurrent use.

funcMetrics

func Metrics() []*Metric

Metrics returns the sorted list of metrics.

The returned slice should not be mutated.

funcNewCounter

func NewCounter(namestring) *Metric

NewCounter returns a new metric that can only increment.

funcNewCounterFuncadded inv1.40.0

func NewCounterFunc(namestring, f func()int64) *Metric

NewCounterFunc returns a counter metric that has its value determined bycalling the provided function (calling Add() and Set() will panic). Nolocking guarantees are made for the invocation.

funcNewGauge

func NewGauge(namestring) *Metric

NewGauge returns a new metric that can both increment and decrement.

funcNewGaugeFuncadded inv1.40.0

func NewGaugeFunc(namestring, f func()int64) *Metric

NewGaugeFunc returns a gauge metric that has its value determined bycalling the provided function (calling Add() and Set() will panic). Nolocking guarantees are made for the invocation.

funcNewUnpublished

func NewUnpublished(namestring, typType) *Metric

NewUnpublished initializes a new Metric without calling Publish onit.

func (*Metric)Add

func (m *Metric) Add(nint64)

Add increments m's value by n.

If m is of type counter, n should not be negative.

func (*Metric)DisableDeltasadded inv1.40.0

func (m *Metric) DisableDeltas()

DisableDeltas disables uploading of deltas for this metric (absolute valuesare always uploaded).

func (*Metric)Name

func (m *Metric) Name()string

func (*Metric)Publish

func (m *Metric) Publish()

Publish registers a metric in the global map.It panics if the name is a duplicate anywhere in the process.

func (*Metric)Set

func (m *Metric) Set(vint64)

Set sets m's value to v.

If m is of type counter, Set should not be used.

func (*Metric)Type

func (m *Metric) Type()Type

func (*Metric)Value

func (m *Metric) Value()int64

typeType

type Typeuint8

Type is a metric type: counter or gauge.

const (TypeGaugeType =iotaTypeCounter)

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp