Counters, gauges and histograms for the replikativ stack — konserve, datahike,
kabel — with Prometheus exposition and nothing underneath: no dependencies, one
.cljc registry that runs on the JVM, Node and in the browser, and a JVM
sampler that reads the platform MXBeans under the names the stock Grafana JVM
dashboards expect. The sibling of replikativ/logging.
org.replikativ/metrics {:mvn/version "0.1.x"} ; see the releases
(require '[replikativ.metrics :as m])
(m/describe! :datahike_commit_seconds {:type :histogram :help "Commit latency"})
(m/inc! :datahike_transactions_total {:database db-id})
(m/gauge! :datahike_connections {:database db-id} 3)
(m/observe! :datahike_commit_seconds {:database db-id} 0.042)
(let [t0 (m/timer)] … (m/observe-since! :datahike_commit_seconds {:database db-id} t0))
Names are keywords in Prometheus style (snake_case, unit last: _seconds,
_bytes, _total for counters); labels a map of keyword to keyword, string,
number or uuid. Recording is one swap! on an atom — safe from any thread,
cheap, never throws for a well-formed call. describe! adds the help text
and, for histograms, the buckets (default-buckets are 1 ms … 10 s); an
instrument first seen by a recording call gets its type from the call.
(require '[replikativ.metrics.prometheus :as prometheus]
'[replikativ.metrics.jvm :as jvm]) ; JVM only
;; a Ring handler for /metrics
(fn [_] {:status 200
:headers {"content-type" "text/plain; version=0.0.4"}
:body (prometheus/text (m/snapshot) (jvm/samples))})
snapshot is plain data ({name {:type :help :buckets :series {labels state}}}),
so anything else — a bridge into micrometer for CloudWatch or OTLP, a test
assertion — is a function over it. The JVM samples cover memory per pool,
GC counts and time, threads, classes, CPU and uptime.
konserve reports every store operation to its own sinks; this sink turns
those events into konserve_operation_seconds{backend,store_id,op,level},
konserve_operation_errors_total, konserve_lock_wait_seconds and
konserve_bytes_written_total:
(require '[replikativ.metrics.konserve :as k])
(k/describe!)
(konserve.metrics/add-sink! ::prometheus k/sink)
clojure -M:test # JVM
npx shadow-cljs compile node-test && node out/node-tests.js # Node
clojure -M:format # cljfmt
Copyright © 2026 Christian Weilbach. Licensed under the Apache License, Version 2.0.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |