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.
Initially opened as #165, but I no longer have permission to push to the origin
used for that PR. The only change is I fixed the conflict (two branches added
tests at the bottom of the same file)
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.
Initially opened as #165, but I no longer have permission to push to the origin used for that PR. The only change is I fixed the conflict (two branches added tests at the bottom of the same file)