本文整理了Java中com.codahale.metrics.graphite.Graphite.<init>()
方法的一些代码示例,展示了Graphite.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphite.<init>()
方法的具体详情如下:
包路径:com.codahale.metrics.graphite.Graphite
类名称:Graphite
方法名:<init>
[英]Creates a new client which connects to the given address using the default SocketFactory.
[中]创建一个使用默认SocketFactory连接到给定地址的新客户端。
代码示例来源:origin: apache/nifi
/**
* Create a sender.
*
* @param host the hostname of the server to connect to.
* @param port the port on which the server listens.
* @param charset the charset in which the server expects logs.
* @return The created sender.
*/
protected GraphiteSender createSender(String host, int port, Charset charset) {
return new Graphite(host, port, SocketFactory.getDefault(), charset);
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public GraphiteSender createConnection(String hostname, int port) {
return new Graphite(new InetSocketAddress(hostname, port));
}
}, UDP {
代码示例来源:origin: dropwizard/dropwizard
@Override
public ScheduledReporter build(MetricRegistry registry) {
GraphiteReporter.Builder builder = builder(registry);
if ("udp".equalsIgnoreCase(transport)) {
return builder.build(new GraphiteUDP(host, port));
} else {
return builder.build(new Graphite(host, port));
}
}
代码示例来源:origin: thinkaurelius/titan
/**
* Create a {@link GraphiteReporter} attached to the Titan Metrics registry.
* <p>
* If {@code prefix} is null, then Metrics's internal default prefix is used
* (empty string at the time this comment was written).
*
* @param host
* the host to which Graphite reports are sent
* @param port
* the port to which Graphite reports are sent
* @param prefix
* the optional metrics prefix
* @param reportInterval
* time to wait between sending metrics to the configured
* Graphite host and port
*/
public synchronized void addGraphiteReporter(String host, int port,
String prefix, Duration reportInterval) {
Preconditions.checkNotNull(host);
Graphite graphite = new Graphite(new InetSocketAddress(host, port));
GraphiteReporter.Builder b = GraphiteReporter
.forRegistry(getRegistry());
if (null != prefix)
b.prefixedWith(prefix);
b.filter(MetricFilter.ALL);
graphiteReporter = b.build(graphite);
graphiteReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS);
log.info("Configured Graphite reporter host={} interval={} port={} prefix={}",
new Object[] { host, reportInterval, port, prefix });
}
代码示例来源:origin: JanusGraph/janusgraph
/**
* Create a {@link GraphiteReporter} attached to the JanusGraph Metrics registry.
* <p>
* If {@code prefix} is null, then Metrics's internal default prefix is used
* (empty string at the time this comment was written).
*
* @param host
* the host to which Graphite reports are sent
* @param port
* the port to which Graphite reports are sent
* @param prefix
* the optional metrics prefix
* @param reportInterval
* time to wait between sending metrics to the configured
* Graphite host and port
*/
public synchronized void addGraphiteReporter(String host, int port,
String prefix, Duration reportInterval) {
Preconditions.checkNotNull(host);
Graphite graphite = new Graphite(new InetSocketAddress(host, port));
GraphiteReporter.Builder b = GraphiteReporter
.forRegistry(getRegistry());
if (null != prefix)
b.prefixedWith(prefix);
b.filter(MetricFilter.ALL);
graphiteReporter = b.build(graphite);
graphiteReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS);
log.info("Configured Graphite reporter host={} interval={} port={} prefix={}",
host, reportInterval, port, prefix);
}
代码示例来源:origin: Alluxio/alluxio
/**
* Creates a new {@link GraphiteSink} with a {@link Properties} and {@link MetricRegistry}.
*
* @param properties the properties which may contain polling period and unit properties
* @param registry the metric registry to register
* @throws IllegalArgumentException if the {@code host} or {@code port} property is missing
*/
public GraphiteSink(Properties properties, MetricRegistry registry)
throws IllegalArgumentException {
mProperties = properties;
String host = properties.getProperty(GRAPHITE_KEY_HOST);
String port = properties.getProperty(GRAPHITE_KEY_PORT);
if (host == null || port == null) {
throw new IllegalArgumentException("Graphite sink requires 'host' and 'port' properties");
}
String prefix = properties.getProperty(GRAPHITE_KEY_PREFIX);
if (prefix == null) {
prefix = GRAPHITE_DEFAULT_PREFIX;
}
Graphite graphite = new Graphite(host, Integer.parseInt(port));
mReporter =
GraphiteReporter.forRegistry(registry).convertDurationsTo(TimeUnit.MILLISECONDS)
.convertRatesTo(TimeUnit.SECONDS).prefixedWith(prefix).build(graphite);
MetricsSystem.checkMinimalPollingPeriod(getPollUnit(), getPollPeriod());
}
代码示例来源:origin: apache/usergrid
@Inject
public MetricsFactoryImpl(MetricsFig metricsFig) {
registry = new MetricRegistry();
String metricsHost = metricsFig.getHost();
if (!metricsHost.equals("false")) {
Graphite graphite = new Graphite(new InetSocketAddress(metricsHost, 2003));
graphiteReporter = GraphiteReporter.forRegistry(registry).prefixedWith("usergrid-metrics")
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL)
.build(graphite);
graphiteReporter.start(30, TimeUnit.SECONDS);
} else {
logger.warn("MetricsService:Logger not started.");
}
jmxReporter = JmxReporter.forRegistry(registry).build();
jmxReporter.start();
}
代码示例来源:origin: stagemonitor/stagemonitor
private void reportToGraphite(MetricRegistry metricRegistry, long reportingInterval, MeasurementSession measurementSession) {
if (isReportToGraphite()) {
final GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
.prefixedWith(getGraphitePrefix(measurementSession))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build(new Graphite(new InetSocketAddress(getGraphiteHostName(), getGraphitePort())));
graphiteReporter.start(reportingInterval, TimeUnit.SECONDS);
reporters.add(graphiteReporter);
}
}
代码示例来源:origin: apache/flink
case TCP:
default:
return builder.build(new Graphite(host, port));
代码示例来源:origin: apache/incubator-druid
public ConsumerRunnable()
{
if (graphiteEmitterConfig.getProtocol().equals(GraphiteEmitterConfig.PLAINTEXT_PROTOCOL)) {
graphite = new Graphite(
graphiteEmitterConfig.getHostname(),
graphiteEmitterConfig.getPort()
);
} else {
graphite = new PickledGraphite(
graphiteEmitterConfig.getHostname(),
graphiteEmitterConfig.getPort(),
graphiteEmitterConfig.getBatchSize()
);
}
log.info("Using %s protocol.", graphiteEmitterConfig.getProtocol());
}
代码示例来源:origin: apache/storm
sender = new GraphiteUDP(host, port);
} else {
sender = new Graphite(host, port);
代码示例来源:origin: ninjaframework/ninja
sender = new PickledGraphite(graphiteAddress);
} else {
sender = new Graphite(graphiteAddress);
代码示例来源:origin: uber/chaperone
private static Graphite getGraphite() {
if (AuditConfig.GRAPHITE_HOST_NAME == null || AuditConfig.GRAPHITE_PORT == 0
|| AuditConfig.GRAPHITE_REPORT_PERIOD_SEC == 0L) {
return null;
}
InetSocketAddress graphiteAddress =
new InetSocketAddress(AuditConfig.GRAPHITE_HOST_NAME, AuditConfig.GRAPHITE_PORT);
return new Graphite(graphiteAddress);
}
}
代码示例来源:origin: uber/chaperone
static Graphite getGraphite(ControllerConf config) {
if (config.getGraphiteHost() == null || config.getGraphitePort() == 0) {
LOGGER.warn("No Graphite built!");
return null;
}
InetSocketAddress graphiteAddress =
new InetSocketAddress(config.getGraphiteHost(), config.getGraphitePort());
LOGGER.warn(String.format("Trying to connect to Graphite with address: %s",
graphiteAddress.toString()));
return new Graphite(graphiteAddress);
}
代码示例来源:origin: apache/tinkerpop
/**
* Create a {@link GraphiteReporter} attached to the {@code MetricsRegistry}.
* <p/>
* If {@code prefix} is null, then Metrics's internal default prefix is used
* (empty string at the time this comment was written).
*
* @param host the host to which Graphite reports are sent
* @param port the port to which Graphite reports are sent
* @param prefix the optional metrics prefix
* @param reportIntervalInMS milliseconds to wait between sending metrics to the configured
* Graphite host and port
*/
public synchronized void addGraphiteReporter(final String host, final int port,
final String prefix, final long reportIntervalInMS) {
if (host == null || host.isEmpty())
throw new IllegalArgumentException("Host cannot be null or empty");
Graphite graphite = new Graphite(new InetSocketAddress(host, port));
GraphiteReporter.Builder b = GraphiteReporter
.forRegistry(getRegistry());
if (null != prefix)
b.prefixedWith(prefix);
b.filter(MetricFilter.ALL);
graphiteReporter = b.build(graphite);
graphiteReporter.start(reportIntervalInMS, TimeUnit.MILLISECONDS);
log.info("Configured Graphite reporter host={} interval={}ms port={} prefix={}",
new Object[]{host, reportIntervalInMS, port, prefix});
}
代码示例来源:origin: pippo-java/pippo
@Override
public void start(PippoSettings settings, MetricRegistry metricRegistry) {
if (settings.getBoolean("metrics.graphite.enabled", false)) {
String hostname = settings.getLocalHostname();
String address = settings.getRequiredString("metrics.graphite.address");
int port = settings.getInteger("metrics.graphite.port", 2003);
boolean isPickled = settings.getBoolean("metrics.graphite.pickled", false);
long period = settings.getDurationInSeconds("metrics.graphite.period", 60);
InetSocketAddress graphiteAddress = new InetSocketAddress(address, port);
GraphiteSender sender;
if (isPickled) {
sender = new PickledGraphite(graphiteAddress);
} else {
sender = new Graphite(graphiteAddress);
}
reporter = GraphiteReporter.forRegistry(metricRegistry)
.prefixedWith(hostname)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.filter(MetricFilter.ALL)
.build(sender);
reporter.start(period, TimeUnit.SECONDS);
log.debug("Started Graphite Metrics reporter for '{}', updating every {} seconds", hostname, period);
} else {
log.debug("Graphite Metrics reporter is disabled");
}
}
代码示例来源:origin: ryantenney/metrics-spring
graphite = new Graphite(hostname, port, SocketFactory.getDefault(), charset);
代码示例来源:origin: uber/uReplicator
static Graphite getGraphite(ControllerConf config) {
if (config.getGraphiteHost() == null || config.getGraphitePort() == 0) {
LOGGER.warn("No Graphite built!");
return null;
}
InetSocketAddress graphiteAddress =
new InetSocketAddress(config.getGraphiteHost(), config.getGraphitePort());
LOGGER.info(String.format("Trying to connect to Graphite with address: %s",
graphiteAddress.toString()));
return new Graphite(graphiteAddress);
}
代码示例来源:origin: uber/uReplicator
static Graphite getGraphite(ManagerConf config) {
if (config.getGraphiteHost() == null || config.getGraphitePort() == 0) {
LOGGER.warn("No Graphite built!");
return null;
}
InetSocketAddress graphiteAddress =
new InetSocketAddress(config.getGraphiteHost(), config.getGraphitePort());
LOGGER.info(String.format("Trying to connect to Graphite with address: %s",
graphiteAddress.toString()));
return new Graphite(graphiteAddress);
}
代码示例来源:origin: uber/hudi
private GraphiteReporter createGraphiteReport() {
Graphite graphite = new Graphite(new InetSocketAddress(serverHost, serverPort));
String reporterPrefix = config.getGraphiteMetricPrefix();
return GraphiteReporter.forRegistry(registry).prefixedWith(reporterPrefix)
.convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS)
.filter(MetricFilter.ALL).build(graphite);
}
}
内容来源于网络,如有侵权,请联系作者删除!