Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 809 Bytes

README.md

File metadata and controls

36 lines (26 loc) · 809 Bytes

Statistics library for Go

Documentation on https://godoc.org/github.com/Brickchain/go-stats.v1.

Based on go-metrics.

Simplifies setup of metrics sinks and collecting statistics.

Usage

package main

import (
    "os"
    "time"
    "path"

    stats "github.com/Brickchain/go-stats.v1"
)

func main() {
    // start an inmem metrics sink that will print metrics once per minute.
    // set the instance name to the name of our binary.
    stats.Setup("inmem", path.Base(os.Args[0]))

    someFunc()

    // Wait a bit more than a minute in order to see the metrics being printed
    time.Sleep(time.Second * 62)
}

func someFunc() {
    t := stats.StartTimer("someFunc.total")
    defer t.Stop()
}