Closed eranharel closed 5 years ago
When RegisterDebugGCStats and RegisterRuntimeMemStats are accidentally called more than once the CaptureXxx function will report zero values due unprotected override of the metrics stored in debugMetrics and runtimeMetrics
RegisterDebugGCStats
RegisterRuntimeMemStats
debugMetrics
runtimeMetrics
Example test case:
func TestDebugGCStatsDoubleRegister(t *testing.T) { r := NewRegistry() RegisterDebugGCStats(r) runtime.GC() CaptureDebugGCStatsOnce(r) if numGC := debugMetrics.GCStats.NumGC.Value(); 1 != numGC { t.Errorf("NumGC got %d, expected 1", numGC) } RegisterDebugGCStats(r) if numGC := debugMetrics.GCStats.NumGC.Value(); 1 != numGC { t.Errorf("NumGC got %d, expected 1", numGC) } }
When
RegisterDebugGCStats
andRegisterRuntimeMemStats
are accidentally called more than once the CaptureXxx function will report zero values due unprotected override of the metrics stored indebugMetrics
andruntimeMetrics
Example test case: