Skip to content

Commit

Permalink
usm: telemetry: tests: Move Clear method to test only file (DataDog#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
guyarb authored Dec 10, 2024
1 parent bf79e39 commit 8a450cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
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()
}

0 comments on commit 8a450cc

Please sign in to comment.