forked from rcrowley/go-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document how to create a threadsafe registry
My first iteration of a metrics client had code like this: ```go // 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.
- Loading branch information
1 parent
6ee5318
commit 7282ad6
Showing
4 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters