package statsd
import "github.com/streadway/handy/statsd"
Package statsd collects and reports telemetry from http handlers.
Index ¶
- func Codes(statsd io.Writer, key string, interval time.Duration, next http.Handler) http.Handler
- func Durations(statsd io.Writer, key string, interval time.Duration, next http.Handler) http.Handler
Examples ¶
Functions ¶
func Codes ¶
Codes collects and reports the counts of response codes for the handler chain for all requests.
Code:play
Example¶
package main
import (
"github.com/streadway/handy/statsd"
"io"
"io/ioutil"
"net"
"net/http"
"time"
)
func main() {
var remote io.Writer
remote, err := net.Dial("udp", "127.0.0.1:8126")
if err != nil {
// log error and continue
remote = ioutil.Discard
}
http.ListenAndServe(":8080",
statsd.Codes(remote, "doc.status", 10*time.Second,
http.FileServer(http.Dir("/usr/share/doc"))))
}
func Durations ¶
func Durations(statsd io.Writer, key string, interval time.Duration, next http.Handler) http.Handler
Durations writes a statsd formatted packet to the io.Writer with a list of durations recorded for each reporting interval or until a packet is filled.
Source Files ¶
- Version
- v0.0.0-20200128134331-0f66f006fb2e (latest)
- Published
- Jan 28, 2020
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 2 months ago –
Tools for package owners.