本文整理汇总了Java中com.timgroup.statsd.NoOpStatsDClient类的典型用法代码示例。如果您正苦于以下问题:Java NoOpStatsDClient类的具体用法?Java NoOpStatsDClient怎么用?Java NoOpStatsDClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoOpStatsDClient类属于com.timgroup.statsd包,在下文中一共展示了NoOpStatsDClient类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createClient
import com.timgroup.statsd.NoOpStatsDClient; //导入依赖的package包/类
private StatsDClient createClient(String statsdHost, int port) {
StatsDClientErrorHandler errorHandler = new StatsDClientErrorHandler() {
@Override
public void handle(Exception exception) {
log.error("Error sending to statsd: " + ExceptionToString.format(exception));
}
};
if (statsdHost == null) {
log.fatal("Error, statsd host not set. It needs to be set in RaptureMETRICS.cfg");
return new NoOpStatsDClient();
} else {
try {
InetAddress address = InetAddress.getByName(statsdHost);
String ip = address.getHostAddress();
log.info(String.format("statsd host=%s, ip=%s", statsdHost, ip));
return createClient(ip, port, errorHandler);
} catch (UnknownHostException e) {
log.error(String.format("Error resolving statsd host ip. hostname=%s - %s", statsdHost, ExceptionToString.format(e)));
return createClient(statsdHost, port, errorHandler);
}
}
}
示例2: createStatsDClient
import com.timgroup.statsd.NoOpStatsDClient; //导入依赖的package包/类
/**
* Returns an initialized instance of the StatsDClient If StatsD is enabled
* this is a NonBlockingStatsDClient which guarantees not to block the thread or
* throw exceptions. If StatsD is not enabled it creates a NoOpStatsDClient which
* contains all empty methods
*
* @return initialized StatsDClient
*/
protected StatsDClient createStatsDClient() {
if (kafkaProducerConfiguration.getStatsDConfiguration() != null) {
final String prefix = kafkaProducerConfiguration.getStatsDConfiguration().getPrefix();
final String host = kafkaProducerConfiguration.getStatsDConfiguration().getHost();
final int port = kafkaProducerConfiguration.getStatsDConfiguration().getPort();
return new NonBlockingStatsDClient(prefix, host, port);
} else {
return new NoOpStatsDClient();
}
}
示例3: createStatsDClient
import com.timgroup.statsd.NoOpStatsDClient; //导入依赖的package包/类
/**
* Returns an initialized instance of the StatsDClient If StatsD is enabled
* this is a NonBlockingStatsDClient which guarantees not to block the thread or
* throw exceptions. If StatsD is not enabled it creates a NoOpStatsDClient which
* contains all empty methods
*
* @return initialized StatsDClient
*/
protected StatsDClient createStatsDClient() {
final boolean enabled = getOptionalBooleanConfig(STATSD_ENABLED, DEFAULT_STATSD_ENABLED);
if (enabled) {
final String prefix = getOptionalStringConfig(STATSD_PREFIX, DEFAULT_STATSD_PREFIX);
final String host = getOptionalStringConfig(STATSD_HOST, DEFAULT_STATSD_HOST);
final int port = getOptionalIntConfig(STATSD_PORT, DEFAULT_STATSD_PORT);
return new NonBlockingStatsDClient(prefix, host, port);
}
else {
return new NoOpStatsDClient();
}
}
示例4: statsDClient
import com.timgroup.statsd.NoOpStatsDClient; //导入依赖的package包/类
@Provides
StatsDClient statsDClient(DataDogConfig config) {
return config.enabled()
? new NonBlockingStatsDClient(null, config.host(), config.port())
: new NoOpStatsDClient();
}
示例5: capabilities
import com.timgroup.statsd.NoOpStatsDClient; //导入依赖的package包/类
@Test
public void capabilities() {
reporter = new StatsdReporter(new NoOpStatsDClient());
assertEquals(CapableOf.REPORTING, reporter.capabilities());
}
示例6: buildingWithStatsDClientProvidedIsOkay
import com.timgroup.statsd.NoOpStatsDClient; //导入依赖的package包/类
@Test
public void buildingWithStatsDClientProvidedIsOkay() {
config.setLivenessMetric("whatever");
assertNotNull(config.build(new NoOpStatsDClient()));
}