2018-02-23 09:56:08 +00:00
|
|
|
// Go port of Coda Hale's Metrics library
|
2015-07-07 00:54:22 +00:00
|
|
|
//
|
2018-02-23 09:56:08 +00:00
|
|
|
// <https://github.com/rcrowley/go-metrics>
|
2015-07-07 00:54:22 +00:00
|
|
|
//
|
2018-02-23 09:56:08 +00:00
|
|
|
// Coda Hale's original work: <https://github.com/codahale/metrics>
|
2015-06-27 15:12:58 +00:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2021-07-03 07:44:23 +00:00
|
|
|
"runtime/metrics"
|
2021-03-09 06:34:13 +00:00
|
|
|
"sync/atomic"
|
2015-06-27 15:12:58 +00:00
|
|
|
)
|
|
|
|
|
2021-03-09 06:34:13 +00:00
|
|
|
// callbacks - storing list of callbacks as type []func()
|
|
|
|
// use metrics.AddCallback to add your function to metrics collection loop (to avoid multiple goroutines collecting metrics)
|
|
|
|
var callbacks atomic.Value
|
|
|
|
|
|
|
|
func init() {
|
2021-07-03 07:44:23 +00:00
|
|
|
metrics.All()
|
2021-03-09 06:34:13 +00:00
|
|
|
callbacks.Store([]func(){})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calling Load method
|