Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usm: telemetry: tests: Move Clear method to test only file #31981

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions pkg/network/protocols/telemetry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
19 changes: 19 additions & 0 deletions pkg/network/protocols/telemetry/registry_testutil.go
Original file line number Diff line number Diff line change
@@ -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()
}
Loading