From c7d68d04d8d5301e20ece17a42a7d868d447b5f7 Mon Sep 17 00:00:00 2001 From: Taylor Wood Date: Wed, 28 Jun 2017 10:54:21 -0500 Subject: [PATCH] Add Graphite instance argument to reporter in case you need to use a non-InetSocketAddress Graphite constructor --- docs/source/aggregation.rst | 6 ++++++ metrics-clojure-graphite/src/metrics/reporters/graphite.clj | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/source/aggregation.rst b/docs/source/aggregation.rst index facfbb0..069b178 100644 --- a/docs/source/aggregation.rst +++ b/docs/source/aggregation.rst @@ -37,6 +37,7 @@ ten seconds. Optional arguments to graphite/reporter are: +- :graphite - :host - :port - :prefix @@ -45,6 +46,11 @@ Optional arguments to graphite/reporter are: - :duration-unit - :filter +Note: The :graphite argument allows an existing ``com.codahale.metrics.graphite.Graphite`` +instance to be specified. If specified, this instance will be used rather than a new +instance constructed using the :host and :port arguments. This is useful if you need +to supply a specially-constructed Graphite instance. + Sending Metrics to Ganglia -------------------------- diff --git a/metrics-clojure-graphite/src/metrics/reporters/graphite.clj b/metrics-clojure-graphite/src/metrics/reporters/graphite.clj index 7ac7b58..a1bc5c6 100644 --- a/metrics-clojure-graphite/src/metrics/reporters/graphite.clj +++ b/metrics-clojure-graphite/src/metrics/reporters/graphite.clj @@ -22,9 +22,10 @@ (defn ^com.codahale.metrics.graphite.GraphiteReporter reporter ([opts] (reporter default-registry opts)) - ([^MetricRegistry reg {:keys [host hostname port prefix clock rate-unit duration-unit filter] :as opts + ([^MetricRegistry reg {:keys [graphite host hostname port prefix clock rate-unit duration-unit filter] :as opts :or {port 2003}}] - (let [g (graphite-sender (or host hostname "localhost") port) + (let [g (or graphite + (graphite-sender (or host hostname "localhost") port)) b (builder-for-registry reg)] (when-let [^String s prefix] (.prefixedWith b s))