clj-commons / metrics-clojure

A thin façade around Coda Hale's metrics library.
http://metrics-clojure.rtfd.org/
MIT License
342 stars 82 forks source link

Why `default.default` is added when metric name is string? #110

Closed ronaldsuwandi closed 8 years ago

ronaldsuwandi commented 8 years ago

Trying to understand metric-name function

(defn ^String metric-name
  [title]
  (if (string? title)
    (MetricRegistry/name "default"
                         ^"[Ljava.lang.String;" (into-array String ["default" ^String title]))
    (MetricRegistry/name
     ^String (first title)
     ^"[Ljava.lang.String;" (into-array String
                                        (if (= 3 (count title))
                                          [(second title) (last title)]
                                          (rest title))))))

https://github.com/sjl/metrics-clojure/blob/master/metrics-clojure-core/src/metrics/core.clj#L19

Why do you need to append default.default if a normal string is provided as the metric name? MetricRegistry/name seems to accept normal string fine without list of strings

michaelklishin commented 8 years ago

Because metrics need to have a group (or at least it was required way back when this project was started). If you want to provide your own group name, pass in a pair of group name and metric name.