Metrics of your Clojure nREPL
Metrepl is a nREPL middleware that get metrics about your REPL usage (startup time, ops, eval, load-file, errors, client info and more) and export to multiple configurable places. This is useful to have metrics about the REPL usage and understand how users are using its features, if they are facing a specific problem, slowness.
echo '{:exporters {:stdout {:enabled? true}}}' > .metrepl.edn
- create a metrepl config in your project (there are other ways to configure, check configuration)- Add metrepl middleware:
- Leiningen: Add in your
project.clj
or~/.lein/profiles.clj
:
- Leiningen: Add in your
:repl {:dependencies [[dev.ericdallo/metrepl "x.y.z"]]
:repl-options {:nrepl-middleware [metrepl.middleware.op-metrics/wrap-op-metrics
metrepl.middleware.tests-metrics/wrap-tests-metrics]}}
- Clojure: Add in your
deps.edn
or~/.clojure/deps.edn
{:aliases {:cider/nrepl {:extra-deps {dev.ericdallo/metrepl {:mvn/version "x.y.z"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware metrepl/middleware]"]}}}
Metrepl follows a standard of <type>/<metrics-id>
, example: event/op-completed
and each metric may have additional info in its payload
, besides that all metrics have information about the os, hostname and unique id for the nREPL session.
For all available metrics, check here.
Available exporters:
stdout
: Export the metric to current nREPL process stdout, useful for debugging.file
: Export the metric to a file, appending each metric in a new line.otlp
: Export the metric via OpenTelemetry to what user configured.
By default no exporter is enabled, you need to manually configure which one(s) you want to enable, example: {:exporters {:stdout {:enabled? true}}}
.
For all available exporters and their configs, check here.
Metrepl supports a advancded configuration via the following waterfall, merging from top to bottom:
- base: fixed config var
metrepl.config/initial-config
. - classpath: searching for a
metrepl.exports/config.edn
file in the current classpath. - env var: searching for a
METREPL_CONFIG
env var which should contains a valid edn config. - config-file: searching from a local
.metrepl.edn
file. - dynamic-var: the dynamic value in
metrepl.config/*config*
.
Check all available configuration options in all-configs.edn or metrepl.config.
By default, any error on exporting is supressed, to configure that behavior you can set one or more :error-handler
on config, check all-configs.edn
Consider support the work of this project here ❤️