Liking cljdoc? Tell your friends :D

Barometer Clojars Project

Overview

This provides a thin wrapper over Coda Hale's metrics library for the JVM. It provides constructors for Registry and all the individual metrics (e.g., Timer, Meter, Gauge, etc.). Several protocols (Statistical, Metered, Counting, etc.) are extended onto the codahale objects to represent semantically-equivalent access patterns to the original interfaces. A constructor is also provided for the codahale ConsoleReporter for debugging and more!

The preservation of common interfaces is the primary difference between barometer and metrics-clojure.

Besides the thin wrapper, barometer.core does not provide much. The primary novelty introduced is a strict requirement that every metric be accompanied by documentation at its construction (although no effort is made to filter out empty strings). The documentation can be printed/examined by calling protocol methods explain/explanation on the metric. This protocol is also extended onto the Registry, which gives an explanation for all metrics registered at that time.

A simple example of creating and registering a metric:

(def my-registry (m/registry "This registry holds all my metrics."))
(def my-timer (m/timer "This timer times my operation."))
(m/register my-registry :my-lib.package.my-timer my-timer)

A simple example of using a timer:

(m/with-timer the-best-timer
   (println "Test"))

API Documentation

Clojure API documentation can be found here.

Notable features

(barometer.core/default-registry)

A default (initially empty) registry available to all consumers of barometer s.t. the single registry could potentially be shared across libraries.

barometer.core/with-timer

Simple convenience macro that times the execution of the body, even if an exception is thrown. Timer must be supplied.

barometer.aspects/timed

Designed to work with morphe, this allows simple generation of timers attached to functions.

(ns my-ns
  (:require [[morphe.core :as m]
             [barometer.aspects :as ma]])

(m/defn ^{::d/aspects [ma/timed]} my-fn
   [x y z]
   ...
   )

This will create a timer and register it under the default barometer registry under the name "my-ns.my-fn.timer", with the explanation "Timer for the function: my-ns/my-fn".

barometer.aspects/concurrency-measured

Also designed to work with morphe, this allows a way to measure the number of simultaneous in-flight calls to a method.

(ns my-ns
  (:require [[morphe.core :as m]
             [barometer.aspects :as ma]])

(m/defn ^{::d/aspects [ma/concurrency-measured]} my-fn
   [x y z]
   ...
   )

This will create a counter and register it under the default barometer registry under the name "my-ns.my-fn.concurrency-counter", with the explanation "Concurrency counter for the function: my-ns/my-fn".

Can you improve this documentation? These fine people already did:
Tyler Wilding, AJ & Miguel De Dios
Edit on GitHub

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

× close