本文整理了Java中com.yammer.metrics.core.MetricsRegistry.allMetrics()
方法的一些代码示例,展示了MetricsRegistry.allMetrics()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetricsRegistry.allMetrics()
方法的具体详情如下:
包路径:com.yammer.metrics.core.MetricsRegistry
类名称:MetricsRegistry
方法名:allMetrics
[英]Returns an unmodifiable map of all metrics and their names.
[中]返回所有指标及其名称的不可修改映射。
代码示例来源:origin: linkedin/cruise-control
private void reportYammerMetrics(long now) throws Exception {
LOG.debug("Reporting yammer metrics.");
YammerMetricProcessor.Context context = new YammerMetricProcessor.Context(this, now, _brokerId, _reportingIntervalMs);
for (Map.Entry<com.yammer.metrics.core.MetricName, Metric> entry : Metrics.defaultRegistry().allMetrics().entrySet()) {
LOG.trace("Processing yammer metric {}, scope = {}", entry.getKey(), entry.getKey().getScope());
entry.getValue().processWith(_yammerMetricProcessor, entry.getKey(), context);
}
LOG.debug("Finished reporting yammer metrics.");
}
代码示例来源:origin: org.apache.giraph/giraph-core
/**
* Get map of all metrics.
*
* @return Map of all metrics held.
*/
public Map<MetricName, Metric> getAll() {
return registry.allMetrics();
}
代码示例来源:origin: org.apache.giraph/giraph-core
/**
* Get a Gauge that is already present in the MetricsRegistry
*
* @param name String name of Gauge
* @param <T> value type Gauge returns
* @return Gauge<T> from MetricsRegistry
*/
public <T> Gauge<T> getExistingGauge(String name) {
Metric metric = registry.allMetrics().get(makeMetricName(name));
return metric instanceof Gauge ? (Gauge<T>) metric : null;
}
代码示例来源:origin: urbanairship/statshtable
private static void expireOldTimers(MetricsRegistry registry) {
long expireOlderThan = System.currentTimeMillis() - EXPIRE_REGION_TIMERS_MS;
for(Map.Entry<MetricName,Metric> e: registry.allMetrics().entrySet()) {
if(!(e.getValue() instanceof SHTimerMetric)) {
continue;
}
SHTimerMetric metric = (SHTimerMetric)e.getValue();
if(metric.getLastUpdateMillis() < expireOlderThan) {
registry.removeMetric(e.getKey());
}
}
}
代码示例来源:origin: wavefrontHQ/java
@Override
public void run() {
metricsGeneratedLastPass.set(0);
try {
if (includeJvmMetrics) upsertJavaMetrics();
// non-histograms go first
getMetricsRegistry().allMetrics().entrySet().stream().filter(m -> !(m.getValue() instanceof WavefrontHistogram)).
forEach(this::processEntry);
// histograms go last
getMetricsRegistry().allMetrics().entrySet().stream().filter(m -> m.getValue() instanceof WavefrontHistogram).
forEach(this::processEntry);
socketMetricProcessor.flush();
} catch (Exception e) {
logger.log(Level.SEVERE, "Cannot report point to Wavefront! Trying again next iteration.", e);
}
}
代码示例来源:origin: com.linkedin.cruisecontrol/cruise-control-metrics-reporter
private void reportYammerMetrics(long now) throws Exception {
LOG.debug("Reporting yammer metrics.");
YammerMetricProcessor.Context context = new YammerMetricProcessor.Context(this, now, _brokerId, _reportingIntervalMs);
for (Map.Entry<com.yammer.metrics.core.MetricName, Metric> entry : Metrics.defaultRegistry().allMetrics().entrySet()) {
LOG.trace("Processing yammer metric {}, scope = {}", entry.getKey(), entry.getKey().getScope());
entry.getValue().processWith(_yammerMetricProcessor, entry.getKey(), context);
}
LOG.debug("Finished reporting yammer metrics.");
}
代码示例来源:origin: com.yammer.metrics/metrics-core
@Override
public void run() {
final long time = TimeUnit.MILLISECONDS.toSeconds(clock.time() - startTime);
final Set<Entry<MetricName, Metric>> metrics = getMetricsRegistry().allMetrics().entrySet();
try {
for (Entry<MetricName, Metric> entry : metrics) {
final MetricName metricName = entry.getKey();
final Metric metric = entry.getValue();
if (predicate.matches(metricName, metric)) {
final Context context = new Context() {
@Override
public PrintStream getStream(String header) throws IOException {
final PrintStream stream = getPrintStream(metricName, header);
stream.print(time);
stream.print(',');
return stream;
}
};
metric.processWith(this, entry.getKey(), context);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: com.ebay.jetstream/jetstream-messaging
@ManagedAttribute
public Map<String, Object> getStats() {
Map<String, Object> stats = new HashMap<String, Object>();
MetricsRegistry registry = Metrics.defaultRegistry();
for (Entry<MetricName, Metric> e : registry.allMetrics().entrySet()) {
MetricName name = e.getKey();
Metric metric = e.getValue();
if (metric instanceof Meter) {
Meter m = (Meter) metric;
stats.put(name.toString(), new MeterPOJO(m));
} else if (metric instanceof Gauge) {
Gauge<?> g = (Gauge<?>) metric;
stats.put(name.toString(), g.value());
}
}
return stats;
}
}
代码示例来源:origin: amient/kafka-metrics
final Set<Map.Entry<MetricName, Metric>> metrics = getMetricsRegistry().allMetrics().entrySet();
try {
for (Map.Entry<MetricName, Metric> entry : metrics) {
代码示例来源:origin: addthis/metrics-reporter-config
@Override
public void run() {
final Set<Map.Entry<MetricName, Metric>> metrics = getMetricsRegistry().allMetrics().entrySet();
try {
List<DataObject> dataObjectList = new ArrayList<DataObject>();
for (Map.Entry<MetricName, Metric> entry : metrics) {
final MetricName metricName = entry.getKey();
final Metric metric = entry.getValue();
if (predicate.matches(metricName, metric)) {
metric.processWith(this, entry.getKey(), dataObjectList);
}
}
SenderResult senderResult = sender.send(dataObjectList);
if (!senderResult.success()) {
log.warn("metrics reporting to zabbix {} unsuccessful: {}", sender.getHost(), sender.getPort(), senderResult);
} else if (log.isDebugEnabled()) {
log.debug("metrics reported to zabbix {} {}: {}", sender.getHost(), sender.getPort(), senderResult);
}
} catch (Exception e) {
log.error("failed to report metrics to " + sender.getHost() + ':' + sender.getPort(), e);
}
}
}
代码示例来源:origin: amient/kafka-metrics
if (brokerId == controllerId) {
final Map<TopicPartition, Long> logEndOffsets = new HashMap<>();
final Set<Map.Entry<MetricName, Metric>> metrics = getMetricsRegistry().allMetrics().entrySet();
try {
for (Map.Entry<MetricName, Metric> entry : metrics) {
代码示例来源:origin: addthis/MetricCatcher
@Test
public void testCreateMetric_ShortName() {
String name = "test" + Math.random();
jsonMetric.setName(name);
Metric metric = metricCatcher.createMetric(jsonMetric);
Map<MetricName, Metric> allMetrics = Metrics.defaultRegistry().allMetrics();
MetricName metricName = new MetricName(name, "", "");
assertTrue(allMetrics.containsKey(metricName));
Metric actual = allMetrics.get(metricName);
assertEquals(metric, actual);
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server
/**
* Release all associated metrics.
*/
public void release()
{
for(String name : all)
{
allColumnFamilyMetrics.get(name).remove(Metrics.defaultRegistry().allMetrics().get(factory.createMetricName(name)));
Metrics.defaultRegistry().removeMetric(factory.createMetricName(name));
}
readLatency.release();
writeLatency.release();
rangeLatency.release();
Metrics.defaultRegistry().removeMetric(factory.createMetricName("EstimatedRowSizeHistogram"));
Metrics.defaultRegistry().removeMetric(factory.createMetricName("EstimatedRowCount"));
Metrics.defaultRegistry().removeMetric(factory.createMetricName("EstimatedColumnCountHistogram"));
Metrics.defaultRegistry().removeMetric(factory.createMetricName("KeyCacheHitRate"));
Metrics.defaultRegistry().removeMetric(factory.createMetricName("CoordinatorReadLatency"));
Metrics.defaultRegistry().removeMetric(factory.createMetricName("CoordinatorScanLatency"));
Metrics.defaultRegistry().removeMetric(factory.createMetricName("WaitingOnFreeMemtableSpace"));
}
内容来源于网络,如有侵权,请联系作者删除!