README.md: prettifying
This commit is contained in:
parent
adb3c38465
commit
0b4667243b
12
README.md
12
README.md
@ -29,7 +29,7 @@ var (
|
|||||||
requestsTotal = metrics.NewCounter("requests_total")
|
requestsTotal = metrics.NewCounter("requests_total")
|
||||||
|
|
||||||
// Register summary with a single label.
|
// Register summary with a single label.
|
||||||
requestDuration = metrics.NewSummary(`requests_duration_seconds{handler="/my/super/handler"}`)
|
requestDuration = metrics.NewSummary(`requests_duration_seconds{path="/foobar/baz"}`)
|
||||||
|
|
||||||
// Register gauge with two labels.
|
// Register gauge with two labels.
|
||||||
queueSize = metrics.NewGauge(`queue_size{queue="foobar",topic="baz"}`, func() float64 {
|
queueSize = metrics.NewGauge(`queue_size{queue="foobar",topic="baz"}`, func() float64 {
|
||||||
@ -39,14 +39,16 @@ var (
|
|||||||
|
|
||||||
// ...
|
// ...
|
||||||
func requestHandler() {
|
func requestHandler() {
|
||||||
startTime := time.Now()
|
// Increment requestTotal counter.
|
||||||
// ...
|
|
||||||
requestsTotal.Inc()
|
requestsTotal.Inc()
|
||||||
|
|
||||||
|
startTime := time.Now()
|
||||||
|
processRequest()
|
||||||
|
// Update requestDuration summary.
|
||||||
requestDuration.UpdateDuration(startTime)
|
requestDuration.UpdateDuration(startTime)
|
||||||
}
|
}
|
||||||
// ...
|
|
||||||
|
|
||||||
// `/metrics` handler for exposing the registered metrics.
|
// Expose the registered metrics at `/metrics` path.
|
||||||
http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
|
http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
|
||||||
metrics.WritePrometheus(w, true)
|
metrics.WritePrometheus(w, true)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user