https://github.com/dmuth/golang-stats
Stats package for Golang
https://github.com/dmuth/golang-stats
Last synced: about 1 year ago
JSON representation
Stats package for Golang
- Host: GitHub
- URL: https://github.com/dmuth/golang-stats
- Owner: dmuth
- License: other
- Created: 2013-11-04T03:48:50.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2020-09-03T22:21:43.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T11:57:53.120Z (almost 2 years ago)
- Language: Go
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Golang Stats
This is a little package I wrote so that I could keep track of statistics and metrics in
Google Go programs I developed.
### Installation
- Make sure your golib is set up properly:
`export GOLIB=$HOME/golib`
- Now install the package
`go get -v github.com/dmuth/glang-stats`
### Usage
import stats "github.com/dmuth/golang-stats"
//
// Manipulate stats
// The values will be initialized to zero if they do not already exist.
//
stats.IncrStat("key")
stats.DercStat("key")
stats.AddStat("key2", 3)
stats.SubStat("key3", 4)
//
// Retrieve a stat
//
value := stats.Stat("key")
//
// Retrieve all stats as a map[string]int array
//
values := stats.StatAll()
//
// Write all stats to standard output once every 500 ms
//
stats.StatDump(.5)
stats.StatDumpFunc(1, func(data map[string]int) {
// Do something with our stats data once every second
})
### Running the tests
go test -v github.com/dmuth/golang-stats
### Contact
Questions? Complaints? Want to buy me drinks?
Here's my contact info: http://www.dmuth.org/contact