2018-02-23 10:56:08 +01:00
|
|
|
// Go port of Coda Hale's Metrics library
|
2015-07-07 02:54:22 +02:00
|
|
|
//
|
2018-02-23 10:56:08 +01:00
|
|
|
// <https://github.com/rcrowley/go-metrics>
|
2015-07-07 02:54:22 +02:00
|
|
|
//
|
2018-02-23 10:56:08 +01:00
|
|
|
// Coda Hale's original work: <https://github.com/codahale/metrics>
|
2015-06-27 18:12:58 +03:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2021-07-03 14:44:23 +07:00
|
|
|
"runtime/metrics"
|
2021-03-09 13:34:13 +07:00
|
|
|
"sync/atomic"
|
2015-06-27 18:12:58 +03:00
|
|
|
)
|
|
|
|
|
2021-03-09 13:34:13 +07: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 14:44:23 +07:00
|
|
|
metrics.All()
|
2021-03-09 13:34:13 +07:00
|
|
|
callbacks.Store([]func(){})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calling Load method
|