Skip to content

Commit

Permalink
Merge pull request #71 from joho/document_statsd
Browse files Browse the repository at this point in the history
Add documentation for metrics/statsd
  • Loading branch information
peterbourgon committed Jul 11, 2015
2 parents 0e73ced + 0c02864 commit 6080588
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,29 @@ func handleRequest() {
// handle request
}
```

A gauge for the number of goroutines currently running, exported via statsd.
```go
import (
"net"
"os"
"runtime"
"time"

"github.com/go-kit/kit/metrics/statsd"
)

func main() {
statsdWriter, err := net.Dial("udp", "127.0.0.1:8126")
if err != nil {
os.Exit(1)
}

reportingDuration := 5 * time.Second
goroutines := statsd.NewGauge(statsdWriter, "total_goroutines", reportingDuration)
for range time.Tick(reportingDuration) {
goroutines.Set(float64(runtime.NumGoroutine()))
}
}

```

0 comments on commit 6080588

Please sign in to comment.