You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement some clean-up logic on metrics.Set
func generateMetricSet() *metrics.Set {
ms := metrics.NewSet()
total_metrics := 1000
for total_metrics > 0 {
ms.GetOrCreateCounter(RandStringBytesRmndr(50)).Set(uint64(rand.Int63()))
total_metrics--
}
return ms
}
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
func RandStringBytesRmndr(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Int63() % int64(len(letterBytes))]
}
return string(b)
}
func BenchmarkMetricParser_Purge(b *testing.B) {
for i := 0; i < b.N; i++ {
ms := generateMetricSet()
for _,m := range ms.ListMetricNames() {
ms.UnregisterMetric(m)
}
}
}
func BenchmarkMetricParser_Purge2(b *testing.B) {
for i := 0; i < b.N; i++ {
ms := generateMetricSet()
_ = ms
ms = nil
}
}
Hi,
I'm trying to implement some clean-up logic on
metrics.Set
What's is a best approach to do the periodic cleanup?
The text was updated successfully, but these errors were encountered: