iapetos.collector.exceptions

exception-counter

(exception-counter metric & [{:keys [description labels], :or {description "the number and class of encountered exceptions."}}])

Create a new exception counter.

Note that the label exceptionClass will be automatically added.

with-exceptions

macro

(with-exceptions exception-counter & body)

Use the given exception-counter to collect any Exceptions thrown within the given piece of code.

(defonce registry
  (-> (prometheus/collector-registry)
      (prometheus/register
        (exeception-counter :app/exceptions-total))))

(with-exceptions (registry :app/exceptions-total)
  ...)

The exception class will be stored in the counter’s exceptionClass label.