本文整理匯總了Java中com.codahale.metrics.graphite.GraphiteReporter.forRegistry方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphiteReporter.forRegistry方法的具體用法?Java GraphiteReporter.forRegistry怎麽用?Java GraphiteReporter.forRegistry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.codahale.metrics.graphite.GraphiteReporter
的用法示例。
在下文中一共展示了GraphiteReporter.forRegistry方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
if (!graphiteConfiguration.isEnabled()) {
LOG.info("Not reporting data points to graphite.");
return;
}
final String prefix = buildGraphitePrefix();
LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}' and predicates '{}'.", graphiteConfiguration.getHostname(),
graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), prefix, JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()));
final Graphite graphite = new Graphite(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()));
final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);
if (!Strings.isNullOrEmpty(prefix)) {
reporterBuilder.prefixedWith(prefix);
}
if (!graphiteConfiguration.getPredicates().isEmpty()) {
reporterBuilder.filter(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
for (String predicate : graphiteConfiguration.getPredicates()) {
if (name.startsWith(predicate)) {
return true;
}
}
return false;
}
});
}
reporter = Optional.of(reporterBuilder.build(graphite));
reporter.get().start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
示例2: start
import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
if (!graphiteConfiguration.isEnabled()) {
LOG.info("Not reporting data points to graphite.");
return;
}
final String prefix = buildGraphitePrefix();
final Map<String, String> tags = buildGraphiteTags();
LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}', predicates '{}', and tags '{}'.", graphiteConfiguration.getHostname(),
graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), prefix, JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()), JavaUtils.COMMA_EQUALS_MAP_JOINER.join(tags));
graphite = new GraphiteWithTags(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()), SocketFactory.getDefault(), Charsets.UTF_8, tags);
final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);
if (!Strings.isNullOrEmpty(prefix)) {
reporterBuilder.prefixedWith(prefix);
}
if (!graphiteConfiguration.getPredicates().isEmpty()) {
reporterBuilder.filter(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
for (String predicate : graphiteConfiguration.getPredicates()) {
if (name.startsWith(predicate)) {
return true;
}
}
return false;
}
});
}
reporter = reporterBuilder.build(graphite);
reporter.start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
示例3: start
import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
if (!graphiteConfiguration.isEnabled()) {
LOG.info("Not reporting data points to graphite.");
return;
}
LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}' and predicates '{}'.", graphiteConfiguration.getHostname(),
graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), graphiteConfiguration.getPrefix(), JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()));
final Graphite graphite = new Graphite(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()));
final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);
if (!Strings.isNullOrEmpty(graphiteConfiguration.getPrefix())) {
reporterBuilder.prefixedWith(graphiteConfiguration.getPrefix());
}
if (!graphiteConfiguration.getPredicates().isEmpty()) {
reporterBuilder.filter(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
for (String predicate : graphiteConfiguration.getPredicates()) {
if (name.startsWith(predicate)) {
return true;
}
}
return false;
}
});
}
reporter = Optional.of(reporterBuilder.build(graphite));
reporter.get().start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
示例4: start
import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
if (!graphiteConfiguration.isEnabled()) {
LOG.info("Not reporting data points to graphite.");
return;
}
final String prefix = buildGraphitePrefix();
LOG.info("Reporting data points to graphite server {}:{} every {} seconds with prefix '{}' and predicates '{}'.", graphiteConfiguration.getHostname(),
graphiteConfiguration.getPort(), graphiteConfiguration.getPeriodSeconds(), graphiteConfiguration.getPrefix(), JavaUtils.COMMA_JOINER.join(graphiteConfiguration.getPredicates()));
final Graphite graphite = new Graphite(new InetSocketAddress(graphiteConfiguration.getHostname(), graphiteConfiguration.getPort()));
final GraphiteReporter.Builder reporterBuilder = GraphiteReporter.forRegistry(registry);
if (!Strings.isNullOrEmpty(graphiteConfiguration.getPrefix())) {
reporterBuilder.prefixedWith(prefix);
}
if (!graphiteConfiguration.getPredicates().isEmpty()) {
reporterBuilder.filter(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
for (String predicate : graphiteConfiguration.getPredicates()) {
if (name.startsWith(predicate)) {
return true;
}
}
return false;
}
});
}
reporter = Optional.of(reporterBuilder.build(graphite));
reporter.get().start(graphiteConfiguration.getPeriodSeconds(), TimeUnit.SECONDS);
}
示例5: getBuilder
import com.codahale.metrics.graphite.GraphiteReporter; //導入方法依賴的package包/類
GraphiteReporter.Builder getBuilder(MetricRegistry metricRegistry) {
return GraphiteReporter.forRegistry(metricRegistry);
}