From 5cc39fde9559b03584535c0478cc8c105d55e460 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 8 Apr 2019 16:37:53 +0300 Subject: [PATCH] README.md: added `usage` section --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 9fc6922..3eeead3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,30 @@ * It doesn't implement advanced functionality from [github.com/prometheus/client_golang/prometheus](https://godoc.org/github.com/prometheus/client_golang/prometheus). +### Usage + +```go +var ( + requestsTotal = metrics.NewCounter("requests_total") + + queueSize = metrics.NewGauge(`queue_size{queue="foobar"}`, func() float64 { + return float64(foobarQueue.Len()) + }) + + requestDuration = metrics.NewSummary(`requests_duration_seconds{handler="/my/super/handler"}`) +) + +func requestHandler() { + startTime := time.Now() + ... + requestsTotal.Inc() + requestDuration.UpdateDuration(startTime) +} +``` + +See [docs](http://godoc.org/github.com/VictoriaMetrics/metrics) for more info. + + ### Users * `Metrics` has been extracted from [VictoriaMetrics](https://github.com/VictoriaMetrics/VictoriaMetrics) sources.