本文整理汇总了Java中com.codahale.metrics.MetricRegistry.name方法的典型用法代码示例。如果您正苦于以下问题:Java MetricRegistry.name方法的具体用法?Java MetricRegistry.name怎么用?Java MetricRegistry.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codahale.metrics.MetricRegistry
的用法示例。
在下文中一共展示了MetricRegistry.name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerMetric
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
static <T extends Metric> void registerMetric(final scala.Option<ActorRef> owner, final String metricName,
final T metric) {
if (owner.isEmpty()) {
// there's no actor to monitor
return;
}
String actorName = owner.get().path().toStringWithoutAddress();
String fullName = MetricRegistry.name(actorName, metricName);
MetricRegistry registry = MetricsReporter.getInstance(MeteringBehavior.DOMAIN).getMetricsRegistry();
if (registry.getMetrics().containsKey(fullName)) {
// already registered
return;
}
try {
registry.register(fullName, metric);
} catch (IllegalArgumentException e) {
// already registered - shouldn't happen here since we check above...
LOG.debug("Unable to register '{}' in metrics registry: {}", e);
}
}
示例2: apply
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
/**
* Uses 2 timers to measure message processing rate. One for overall message processing rate and
* another to measure rate by message type. The timers are re-used if they were previously created.
*
* <p>
* {@link com.codahale.metrics.MetricRegistry} maintains a reservoir for different timers where
* collected timings are kept. It exposes various metrics for each timer based on collected
* data. Eg: count of messages, 99, 95, 50... percentiles, max, mean etc.
*
* <p>
* These metrics are exposed as JMX bean.
*
* @see <a href="http://dropwizard.github.io/metrics/manual/core/#timers">
* http://dropwizard.github.io/metrics/manual/core/#timers</a>
*
* @param message the message to process
* @throws Exception on message failure
*/
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void apply(final Object message) throws Exception {
final String messageType = message.getClass().getSimpleName();
final String msgProcessingTimeByMsgType =
MetricRegistry.name(actorQualifiedName, MSG_PROCESSING_RATE, messageType);
final Timer msgProcessingTimerByMsgType = metricRegistry.timer(msgProcessingTimeByMsgType);
//start timers
final Timer.Context context = msgProcessingTimer.time();
final Timer.Context contextByMsgType = msgProcessingTimerByMsgType.time();
try {
meteredActor.onReceive(message);
} catch (Throwable e) {
Throwables.propagateIfPossible(e, Exception.class);
throw new RuntimeException(e);
} finally {
//stop timers
contextByMsgType.stop();
context.stop();
}
}
示例3: timer
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
public static Timer timer(String first, String... keys) {
String key = MetricRegistry.name(first, keys);
return (Timer) metricCache.computeIfAbsent(key, (String metricName) -> {
Timer metric = new Timer();
registry.register(metricName, metric);
return metric;
});
}
示例4: meter
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
public static Meter meter(String first, String... keys) {
String key = MetricRegistry.name(first, keys);
return (Meter) metricCache.computeIfAbsent(key, (String metricName) -> {
Meter metric = new Meter();
registry.register(metricName, metric);
return metric;
});
}
示例5: init
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
private void init(final String actorName) {
actorQualifiedName = meteredActor.getSelf().path().parent().toStringWithoutAddress()
+ "/" + actorName;
final String msgProcessingTime = MetricRegistry.name(actorQualifiedName, MSG_PROCESSING_RATE);
msgProcessingTimer = metricRegistry.timer(msgProcessingTime);
}
示例6: submetric
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
public TagEncodedMetricName submetric(String suffix) {
return new TagEncodedMetricName(MetricRegistry.name(metricName, suffix), tags);
}
示例7: metricName
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
private static String metricName(String name) {
return MetricRegistry.name(MetricsS3Decorator.class, name);
}
示例8: getOperationTimer
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
public Timer getOperationTimer(String dataStoreType, String operationName) {
final String rate = MetricRegistry.name(DISTRIBUTED_DATA_STORE_METRIC_REGISTRY, dataStoreType,
operationName, METRIC_RATE);
return metricRegistry.timer(rate);
}
示例9: generateName
import com.codahale.metrics.MetricRegistry; //导入方法依赖的package包/类
/**
* Generates a name for a Metric from its component and feature.
*
* @param component component the metric is defined in
* @param feature feature the metric is defined in
* @param metricName local name of the metric
*
* @return full name of the metric
*/
private String generateName(final MetricsComponent component,
final MetricsFeature feature,
final String metricName) {
return MetricRegistry.name(component.getName(),
feature.getName(),
metricName);
}