Liking cljdoc? Tell your friends :D

daaku.metrics

Clojure API over the Prometheus Java SDK.

This API doesn't try to keep you far away from the Java API. You will likely end up using that API directly. The functions here provide idiomatic (and performant) access to the Collectors.

All Collector creation functions take the same set of options. :name and :help are required, :namespace, :subsystem & :labels are optional.

The expected usage pattern is to create a long lived Collector instance, and use the functions in this package to track the metrics. Most commonly, you will create a package level private var to keep a reference to a metric.

(require '[daaku.metrics :as m])

(def ^:private m-emails-sent (m/counter {:name :emails-sent
                                         :help "emails we sent"}))

(defn- send-email []
  (println "sending email")
  (m/inc m-emails-sent))
Clojure API over the Prometheus Java SDK.

This API doesn't try to keep you far away from the Java API. You
will likely end up using that API directly. The functions here
provide idiomatic (and performant) access to the Collectors.

All Collector creation functions take the same set of
options. `:name` and `:help` are required, `:namespace`,
`:subsystem` & `:labels` are optional.

The expected usage pattern is to create a long lived Collector
instance, and use the functions in this package to track the
metrics. Most commonly, you will create a package level private var
to keep a reference to a metric.

```clojure
(require '[daaku.metrics :as m])

(def ^:private m-emails-sent (m/counter {:name :emails-sent
                                         :help "emails we sent"}))

(defn- send-email []
  (println "sending email")
  (m/inc m-emails-sent))
```
raw docstring

counterclj

(counter opts)

Create a Counter Collector.

Create a Counter Collector.
sourceraw docstring

Decrementcljprotocol

decclj

(dec m)
(dec m amount)

Decrement a Collector by 1 or the given amount.

Decrement a Collector by 1 or the given amount.
source

enumerationclj

(enumeration {:keys [states] :as opts})

Create Enumeration Collector. Also requires :states.

Create Enumeration Collector. Also requires `:states`.
sourceraw docstring

gaugeclj

(gauge opts)

Create Gauge Collector.

Create Gauge Collector.
sourceraw docstring

histogramclj

(histogram opts)

Create Histogram Collector.

Create Histogram Collector.
sourceraw docstring

Incrementcljprotocol

incclj

(inc this)
(inc this amount)

Increment a Collector by 1 or the given amount.

Increment a Collector by 1 or the given amount.
source

infoclj

(info opts)

Create Info Collector.

Create Info Collector.
sourceraw docstring

Observecljprotocol

observeclj

(observe this amount)

Observe a given value.

Observe a given value.

start-timerclj

(start-timer this)

Start a timer. Returns a function that when called will stop the timer.

Start a timer. Returns a function that when called will stop the timer.
source

registerclj

(register r c)

Register into a CollectorRegistry the given Collector.

Register into a CollectorRegistry the given Collector.
sourceraw docstring

sanitize-nameclj

(sanitize-name v)

Sanitize a name to create a safe string suitable as a name, namespace, subsystem or label.

Sanitize a name to create a safe string suitable as a name,
namespace, subsystem or label.
sourceraw docstring

sanitize-valueclj

(sanitize-value v)

Sanitize a value. Keywords are special and their name is used, everything else is transformed to using str.

Sanitize a value. Keywords are special and their name is used,
everything else is transformed to using `str`.
sourceraw docstring

SetInfocljprotocol

set-infoclj

(set-info this info)

Set the information of an Info Collector. Info keys and values will be sanitized.

Set the information of an Info Collector. Info keys and values will
be sanitized.
source

Settablecljprotocol

setclj

(set m amount)

Set a Collector's value to the given amount.

Set a Collector's value to the given amount.
source

Statecljprotocol

set-stateclj

(set-state this state)

Set the state of an Enumeration Collector. State value will be sanitized.

Set the state of an Enumeration Collector. State value will be sanitized.
source

summaryclj

(summary opts)

Create Summary Collector.

Create Summary Collector.
sourceraw docstring

timecljmacro

(time collector & body)

Measure in the Collector the run time duration of the given forms.

Measure in the Collector the run time duration of the given forms.
sourceraw docstring

WithLabelscljprotocol

with-labelsclj

(with-labels this labels)

Create a child with the provided labels.

Create a child with the provided labels.
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close