metrics-clojure is a Clojure façade around Coda Hale’s Metrics library, originally developed by Steve Losh.

metrics-clojure is not a ClojureWerkz project but we help maintain it and consider it to be a very valuable library.

Changes Between 2.1.0 and 2.1.1

Ring Extension Now Respects User-provided Registry

The Ring extension now respects user-provided registries instead of always using the default one.

Contributed by David Smith.

Changes Between 2.0.x and 2.1.0

Ring Extension Supports Multiple Registries and Options

It is now possible to use metrics.ring.expose with a custom registry:

(require '[metrics.ring.expose :refer [expose-metrics-as-json]])

(expose-metrics-as-json ring-app "/ops/metrics" registry {:pretty-print? true})

JVM Instrumentation Extension

The project now also has a JVM instrumentation extension that covers:

  • Number of threads and their states
  • GC stats, heap, off heap memory
  • File descriptors

To enable full instrumenting, use

(require '[metrics.jvm.core :refer [instrument-jvm]])

(instrument-jvm metric-registry)

Contributed by John Cowie (ThoughtWorks).

timers/mean Returns Value (Not Rate)

metrics.timers/mean now returns mean value (not rate) of the timer.

Contributed by Steve Miner.

Ring Extension Updated for 2.0

The Ring extension is now updated for Metrics core 2.0 API.

Contributed by John Cowie (ThoughtWorks).

Changes Between 1.1.0 and 2.0.0

Metrics Registries

metrics-clojure 1.x maintained a metrics registry in a dynamic var. This approach makes the library a little easier for beginners but also much harder to use in more sophisticated cases, e.g. in concurrent applications or those that use a Component-like approach to program structure.

As such, metrics-clojure 2.0+ makes metrics registry a required explicit argument to most functions in the API:

(require '[metrics.meters :as meters])

;; with 1.x
(meters/mark! 10)

;; with 2.0
(let [m (meters/meter ["test" "meters" "test-rate-mean-update-multiple"])]
  (meters/rate-mean m)
  (meters/mark! m 10))

The library maintains a default registry in metrics.core/default-registry which tries to keep the 1.x API as functional as possible but using your own registry is encouraged.

To instantiate a registry, use metrics.core/new-registry:

(require '[metrics.core :as mtr])


See GH #19 for discussion.

defgauge Restricted to Functions Only

In metrics-clojure 1.x, metrics.gauges/defgauge could accept a function or a bunch of forms (body). In 2.0, it only accepts a function. This is in part due to the new API structure but also make the API more straightforward and works much better with explicit registry management now advocated by the library.

Nanoseconds Precision in Timers

Metrics 3.0 uses nanoseconds precision in timers.

Upgrade to Metrics 3.0

Metrics 3.0 is now used internally by the library.

Clojure 1.3 No Longer Supported

Clojure 1.3 is no longer supported by the library.

Full Change Log

metrics-clojure change log is available on GitHub.

About the Author

Michael on behalf of the metrics-clojure Team.