After adding the JVM metrics in I'm seeing that they've got duplicate parts in their names, as per the following example:
prefix.jvm.attribute.attribute.uptime 9494 1407747104
prefix.jvm.file.file 0.01 1407747104
prefix.jvm.gc.gc.PS-Scavenge.time 72 1407747104
prefix.jvm.memory.memory.total.used 208921648 1407747104
prefix.jvm.thread.thread.blocked.count 0 1407747104
This looks like it's down to the way the Metrics library used to have three parts (I think they were called group, class and scope) and metrics-clojure picks out the first
, second
and last
to form the three. In the case of a two item array (which the JVM metrics use) the second of those items is repeated.
Switching the JVM metrics name arrays to a string (e.g. jvm.attribute
) results in the following:
prefix.default.default.jvm.attribute.uptime 9478 1407748160
prefix.default.default.jvm.file 0.01 1407748160
prefix.default.default.jvm.gc.PS-MarkSweep.count 0 1407748160
prefix.default.default.jvm.memory.heap.committed 376963072 1407748160
prefix.default.default.jvm.thread.blocked.count 0 1407748160
... because we're filling in the missing parts with default
instead.
We could add another condition in the metric-name
function in core.clj
which spots that the non-string path handles an array with three items differently from an array with some other number of items.
Alternatively, we could switch to using the newer Metrics 3 style MetricRegistry.name(String, String...)
method instead and just give the title as provided by the user.
The first approach results in more code, the second has the possibility of changing the names of people's metrics without them choosing it.
I'm happy to work up a pull-request with whichever approach you think is best. I personally prefer keeping my metric paths as short as possible and like that Metrics 3 got rid of the 'every metric name must have three parts' idea. The second approach means people can just provide a dotted string for their metric names.