@@ -38,7 +38,9 @@ func Test(t *testing.T) {
38
38
// TestPanic tests that registering two metrics with the same name across any
39
39
// type of metric triggers a panic.
40
40
func (s ) TestPanic (t * testing.T ) {
41
- snapshotMetricsRegistryForTesting (t )
41
+ cleanup := snapshotMetricsRegistryForTesting ()
42
+ defer cleanup ()
43
+
42
44
want := "metric simple counter already registered"
43
45
defer func () {
44
46
if r := recover (); ! strings .Contains (fmt .Sprint (r ), want ) {
@@ -64,7 +66,9 @@ func (s) TestPanic(t *testing.T) {
64
66
// this tests the interactions between the metrics recorder and the metrics
65
67
// registry.
66
68
func (s ) TestMetricRegistry (t * testing.T ) {
67
- snapshotMetricsRegistryForTesting (t )
69
+ cleanup := snapshotMetricsRegistryForTesting ()
70
+ defer cleanup ()
71
+
68
72
intCountHandle1 := RegisterInt64Count (MetricDescriptor {
69
73
Name : "simple counter" ,
70
74
Description : "sum of all emissions from tests" ,
@@ -141,7 +145,9 @@ func (s) TestMetricRegistry(t *testing.T) {
141
145
// metric registry. A component (simulated by test) should be able to record on
142
146
// the different registered int count metrics.
143
147
func TestNumerousIntCounts (t * testing.T ) {
144
- snapshotMetricsRegistryForTesting (t )
148
+ cleanup := snapshotMetricsRegistryForTesting ()
149
+ defer cleanup ()
150
+
145
151
intCountHandle1 := RegisterInt64Count (MetricDescriptor {
146
152
Name : "int counter" ,
147
153
Description : "sum of all emissions from tests" ,
0 commit comments