mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 22:15:51 +00:00
a2c42d3cd4
This commit adds a new usermetric package and wires up metrics across the tailscale client. Updates tailscale/corp#22075 Co-authored-by: Anton Tolchanov <anton@tailscale.com> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
26 lines
472 B
Go
26 lines
472 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package usermetric
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestGauge(t *testing.T) {
|
|
g := NewGauge("test_gauge", "This is a test gauge")
|
|
g.Set(15)
|
|
|
|
var buf bytes.Buffer
|
|
g.WritePrometheus(&buf, "test_gauge")
|
|
const want = `# TYPE test_gauge gauge
|
|
# HELP test_gauge This is a test gauge
|
|
test_gauge 15
|
|
`
|
|
if got := buf.String(); got != want {
|
|
t.Errorf("got %q; want %q", got, want)
|
|
}
|
|
|
|
}
|