My first iteration of a metrics client had code like this:
// Increment a counter with the given name.
func Increment(name string) {
mn := getWithNamespace(name)
m := metrics.GetOrRegister(mn, metrics.NewMeter()).(metrics.Meter)
m.Mark(1)
}
Which contained a massive resource leak - every anonymous NewMeter() call
appends a new arbiter, so I had one arbiter for each function call! Instead
document the right way to do this so people hopefully don't get as lost.
My first iteration of a metrics client had code like this:
Which contained a massive resource leak - every anonymous NewMeter() call appends a new arbiter, so I had one arbiter for each function call! Instead document the right way to do this so people hopefully don't get as lost.