diff --git a/pkg/network/protocols/telemetry/registry.go b/pkg/network/protocols/telemetry/registry.go index d80df1df3394b..a49c997e5899d 100644 --- a/pkg/network/protocols/telemetry/registry.go +++ b/pkg/network/protocols/telemetry/registry.go @@ -60,18 +60,6 @@ func (r *registry) GetMetrics(params ...string) []metric { return result } -// Clear metrics -// WARNING: Only intended for tests -func Clear() { - globalRegistry.Lock() - globalRegistry.metrics = nil - globalRegistry.Unlock() - - telemetryDelta.mux.Lock() - telemetryDelta.stateByClientID = make(map[string]*clientState) - telemetryDelta.mux.Unlock() -} - func init() { globalRegistry = new(registry) } diff --git a/pkg/network/protocols/telemetry/registry_testutil.go b/pkg/network/protocols/telemetry/registry_testutil.go new file mode 100644 index 0000000000000..46777d052b4cc --- /dev/null +++ b/pkg/network/protocols/telemetry/registry_testutil.go @@ -0,0 +1,19 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +//go:build test + +package telemetry + +// Clear metrics +func Clear() { + globalRegistry.Lock() + globalRegistry.metrics = nil + globalRegistry.Unlock() + + telemetryDelta.mux.Lock() + telemetryDelta.stateByClientID = make(map[string]*clientState) + telemetryDelta.mux.Unlock() +}