本文整理匯總了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);
}