aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-08-31 19:00:52 +0100
committerChristopher Baines <mail@cbaines.net>2020-08-31 19:00:52 +0100
commitcbc6e1b03512443a03d66414c426adb8470b5f2b (patch)
tree473eb285a4ea8c6bf71f8efb0c930d01fb27e4a8
parent7752f8f2d31063de44bb972bc4f7359b3277a278 (diff)
downloadprometheus-cbc6e1b03512443a03d66414c426adb8470b5f2b.tar
prometheus-cbc6e1b03512443a03d66414c426adb8470b5f2b.tar.gz
Add more information and an example to the README
-rw-r--r--README45
1 files changed, 45 insertions, 0 deletions
diff --git a/README b/README
index 29aba7e..3f99135 100644
--- a/README
+++ b/README
@@ -2,3 +2,48 @@
This Guile library provides instrumentation code intended to be used
with the Prometheus time series service.
+
+Counter, gauge and histogram metric types are supported.
+
+This client library is still in early development, and there will be
+probably be breaking changes in the future, prior to the first stable
+release.
+
+Some information on how to use this library can be found in the
+docstrings of exported procedures in the prometheus.scm file.
+
+** Web service example
+
+The following example demonstrates a Guile web server, with some
+instrumentation for the number of requests. Each time a request is
+handled, the metric is instrumented. For the /metrics path, the
+response is the metrics and their values. This is intended to be
+scraped by Prometheus so that it can retrieve and record the metric
+values.
+
+#+BEGIN_SRC scheme
+(use-modules (web server)
+ (web request)
+ (web response)
+ (web uri)
+ (prometheus))
+
+(define my-registry (make-metrics-registry #:namespace "exampleapp"))
+
+(define request-counter (make-counter-metric my-registry
+ "requests_count"))
+
+(define (request-handler request body)
+ (metric-increment request-counter)
+
+ (if (equal? (split-and-decode-uri-path (uri-path (request-uri request)))
+ '("metrics"))
+ (values '((content-type . (text/plain)))
+ (lambda (port)
+ (write-metrics my-registry port)))
+ (values '((content-type . (text/plain)))
+ (lambda (port)
+ (display "Incrementing metric\n" port)))))
+
+(run-server request-handler)
+#+END_SRC