erigon-pulse/metrics/metrics_test.go
2022-04-23 15:43:00 +01:00

31 lines
440 B
Go

package metrics
import (
"fmt"
"io"
"log"
"time"
)
// Stop the compiler from complaining during debugging.
var (
_ = io.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
}