Update
This commit is contained in:
33
vendor/tailscale.com/util/clientmetric/clientmetric.go
generated
vendored
33
vendor/tailscale.com/util/clientmetric/clientmetric.go
generated
vendored
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_clientmetrics
|
||||
|
||||
// Package clientmetric provides client-side metrics whose values
|
||||
// get occasionally logged.
|
||||
package clientmetric
|
||||
@@ -18,6 +20,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"tailscale.com/feature/buildfeatures"
|
||||
"tailscale.com/util/set"
|
||||
)
|
||||
|
||||
@@ -55,6 +58,20 @@ const (
|
||||
TypeCounter
|
||||
)
|
||||
|
||||
// MetricUpdate requests that a client metric value be updated.
|
||||
//
|
||||
// This is the request body sent to /localapi/v0/upload-client-metrics.
|
||||
type MetricUpdate struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"` // one of "counter" or "gauge"
|
||||
Value int `json:"value"` // amount to increment by or set
|
||||
|
||||
// Op indicates if Value is added to the existing metric value,
|
||||
// or if the metric is set to Value.
|
||||
// One of "add" or "set". If empty, defaults to "add".
|
||||
Op string `json:"op"`
|
||||
}
|
||||
|
||||
// Metric is an integer metric value that's tracked over time.
|
||||
//
|
||||
// It's safe for concurrent use.
|
||||
@@ -130,15 +147,20 @@ func (m *Metric) Publish() {
|
||||
metrics[m.name] = m
|
||||
sortedDirty = true
|
||||
|
||||
if m.f != nil {
|
||||
lastLogVal = append(lastLogVal, scanEntry{f: m.f})
|
||||
} else {
|
||||
if m.f == nil {
|
||||
if len(valFreeList) == 0 {
|
||||
valFreeList = make([]int64, 256)
|
||||
}
|
||||
m.v = &valFreeList[0]
|
||||
valFreeList = valFreeList[1:]
|
||||
lastLogVal = append(lastLogVal, scanEntry{v: m.v})
|
||||
}
|
||||
|
||||
if buildfeatures.HasLogTail {
|
||||
if m.f != nil {
|
||||
lastLogVal = append(lastLogVal, scanEntry{f: m.f})
|
||||
} else {
|
||||
lastLogVal = append(lastLogVal, scanEntry{v: m.v})
|
||||
}
|
||||
}
|
||||
|
||||
m.regIdx = len(unsorted)
|
||||
@@ -319,6 +341,9 @@ const (
|
||||
// - increment a metric: (decrements if negative)
|
||||
// 'I' + hex(varint(wireid)) + hex(varint(value))
|
||||
func EncodeLogTailMetricsDelta() string {
|
||||
if !buildfeatures.HasLogTail {
|
||||
return ""
|
||||
}
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
|
||||
31
vendor/tailscale.com/util/clientmetric/omit.go
generated
vendored
Normal file
31
vendor/tailscale.com/util/clientmetric/omit.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_clientmetrics
|
||||
|
||||
package clientmetric
|
||||
|
||||
type Metric struct{}
|
||||
|
||||
func (*Metric) Add(int64) {}
|
||||
func (*Metric) Set(int64) {}
|
||||
func (*Metric) Value() int64 { return 0 }
|
||||
func (*Metric) Register(expvarInt any) {}
|
||||
func (*Metric) UnregisterAll() {}
|
||||
|
||||
type MetricUpdate struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Value int `json:"value"`
|
||||
Op string `json:"op"`
|
||||
}
|
||||
|
||||
func HasPublished(string) bool { panic("unreachable") }
|
||||
func EncodeLogTailMetricsDelta() string { return "" }
|
||||
func WritePrometheusExpositionFormat(any) {}
|
||||
|
||||
var zeroMetric Metric
|
||||
|
||||
func NewCounter(string) *Metric { return &zeroMetric }
|
||||
func NewGauge(string) *Metric { return &zeroMetric }
|
||||
func NewAggregateCounter(string) *Metric { return &zeroMetric }
|
||||
Reference in New Issue
Block a user