client/local: add method to set gauge metric to a value
The existing client metric methods only support incrementing (or decrementing) a delta value. This new method allows setting the metric to a specific value. Updates tailscale/corp#35327 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
@@ -58,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.
|
||||
|
||||
@@ -13,6 +13,13 @@ 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) {}
|
||||
|
||||
Reference in New Issue
Block a user