@@ -38,7 +38,9 @@ func Test(t *testing.T) {
3838// TestPanic tests that registering two metrics with the same name across any
3939// type of metric triggers a panic.
4040func (s ) TestPanic (t * testing.T ) {
41- snapshotMetricsRegistryForTesting (t )
41+ cleanup := snapshotMetricsRegistryForTesting ()
42+ defer cleanup ()
43+
4244 want := "metric simple counter already registered"
4345 defer func () {
4446 if r := recover (); ! strings .Contains (fmt .Sprint (r ), want ) {
@@ -64,7 +66,9 @@ func (s) TestPanic(t *testing.T) {
6466// this tests the interactions between the metrics recorder and the metrics
6567// registry.
6668func (s ) TestMetricRegistry (t * testing.T ) {
67- snapshotMetricsRegistryForTesting (t )
69+ cleanup := snapshotMetricsRegistryForTesting ()
70+ defer cleanup ()
71+
6872 intCountHandle1 := RegisterInt64Count (MetricDescriptor {
6973 Name : "simple counter" ,
7074 Description : "sum of all emissions from tests" ,
@@ -141,7 +145,9 @@ func (s) TestMetricRegistry(t *testing.T) {
141145// metric registry. A component (simulated by test) should be able to record on
142146// the different registered int count metrics.
143147func TestNumerousIntCounts (t * testing.T ) {
144- snapshotMetricsRegistryForTesting (t )
148+ cleanup := snapshotMetricsRegistryForTesting ()
149+ defer cleanup ()
150+
145151 intCountHandle1 := RegisterInt64Count (MetricDescriptor {
146152 Name : "int counter" ,
147153 Description : "sum of all emissions from tests" ,
0 commit comments