MCPcopy
hub / github.com/grpc/grpc-go / snapshotMetricsRegistryForTesting

Function snapshotMetricsRegistryForTesting

experimental/stats/metricregistry.go:327–342  ·  view source on GitHub ↗

snapshotMetricsRegistryForTesting snapshots the global data of the metrics registry. Returns a cleanup function that sets the metrics registry to its original state.

()

Source from the content-addressed store, hash-verified

325// registry. Returns a cleanup function that sets the metrics registry to its
326// original state.
327func snapshotMetricsRegistryForTesting() func() {
328 oldDefaultMetrics := DefaultMetrics
329 oldRegisteredMetrics := registeredMetrics
330 oldMetricsRegistry := metricsRegistry
331
332 registeredMetrics = make(map[string]bool)
333 metricsRegistry = make(map[string]*MetricDescriptor)
334 maps.Copy(registeredMetrics, registeredMetrics)
335 maps.Copy(metricsRegistry, metricsRegistry)
336
337 return func() {
338 DefaultMetrics = oldDefaultMetrics
339 registeredMetrics = oldRegisteredMetrics
340 metricsRegistry = oldMetricsRegistry
341 }
342}

Callers 4

TestPanicMethod · 0.85
TestMetricRegistryMethod · 0.85
TestUpDownCountsMethod · 0.85
TestNumerousIntCountsMethod · 0.85

Calls 1

CopyMethod · 0.80

Tested by 4

TestPanicMethod · 0.68
TestMetricRegistryMethod · 0.68
TestUpDownCountsMethod · 0.68
TestNumerousIntCountsMethod · 0.68