mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
31 lines
451 B
Go
31 lines
451 B
Go
package metrics
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
// Stop the compiler from complaining during debugging.
|
|
var (
|
|
_ = ioutil.Discard
|
|
_ = log.LstdFlags
|
|
)
|
|
|
|
func Example() {
|
|
c := NewCounter()
|
|
Register("money", c)
|
|
c.Inc(17)
|
|
|
|
// Threadsafe registration
|
|
t := GetOrRegisterTimer("db.get.latency", nil)
|
|
t.Time(func() { time.Sleep(10 * time.Millisecond) })
|
|
t.Update(1)
|
|
|
|
fmt.Println(c.Count())
|
|
fmt.Println(t.Min())
|
|
// Output: 17
|
|
// 1
|
|
}
|