This commit is contained in:
bluepython508 committed 2026-10-22 12:27:19 +01:00
1 parent 3530afb854
commit 6903fcff27
2146 files changed
+112256 -190703

No files matched your search

+20 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) Tailscale Inc & AUTHORS
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
//go:build !ts_omit_clientmetrics
@@ -22,6 +22,7 @@ import (
"tailscale.com/feature/buildfeatures"
"tailscale.com/util/set"
"tailscale.com/util/testenv"
)
var (
@@ -452,6 +453,24 @@ func (b *deltaEncBuf) writeHexVarint(v int64) {
b.buf.Write(hexBuf)
}
// ResetForTest resets all client metric values to zero.
// It panics if not in a test or if called from a parallel test.
func ResetForTest(t testenv.TB) {
if !testenv.InTest() {
panic("clientmetric.ResetForTest called outside a test")
}
if testenv.InParallelTest(t) {
panic("clientmetric.ResetForTest called from a parallel test")
}
mu.Lock()
defer mu.Unlock()
for _, m := range metrics {
if m.v != nil {
atomic.StoreInt64(m.v, 0)
}
}
}
var TestHooks testHooks
type testHooks struct{}