Permalink
Browse files

Add 'prefix' graphite parameter : value prepended to all metrics name…

…s which are sent to graphite
  • Loading branch information...
walien committed Dec 18, 2014
1 parent 1a48982 commit a7cc0ea8f0df346e48107c20d7c8b136a07f24dc
@@ -20,4 +20,7 @@
Optional<Integer> getFrequency();
@SettingsKey(key = "graphite.reporter.frequency.unit", doc = "the unit in which frequency is expressed", defaultValue = "MINUTES")
Optional<String> getFrequencyUnit();
+
+ @SettingsKey(key = "graphite.prefix", doc = "the value prepended to all metrics names which are sent to graphite")
+ Optional<String> getPrefix();
}
@@ -80,7 +80,16 @@ private void setupGraphiteReporter() {
InetSocketAddress address = new InetSocketAddress(
graphiteSettings.getGraphiteHost().get(), graphiteSettings.getGraphitePort().or(2003));
logger.info("Initializing Metrics Graphite reporting to {}", address);
- GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metrics)
+
+ GraphiteReporter.Builder builder = GraphiteReporter.forRegistry(metrics);
+
+ if (graphiteSettings.getPrefix().isPresent()) {
+ String prefix = graphiteSettings.getPrefix().get();
+ builder.prefixedWith(prefix);
+ logger.info("Metrics Graphite prefix is set to '{}'", prefix);
+ }
+
+ GraphiteReporter graphiteReporter = builder
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build(new Graphite(address));

0 comments on commit a7cc0ea

Please sign in to comment.