本文整理了Java中com.codahale.metrics.Gauge.getValue()
方法的一些代码示例,展示了Gauge.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gauge.getValue()
方法的具体详情如下:
包路径:com.codahale.metrics.Gauge
类名称:Gauge
方法名:getValue
[英]Returns the metric's current value.
[中]返回度量的当前值。
代码示例来源:origin: alibaba/jstorm
/**
* {@inheritDoc}
*/
@Override
public Object getValue(Integer window) {
return this.gauge.getValue();
}
}
代码示例来源:origin: stagemonitor/stagemonitor
private Double getDoubleFromGauge(Gauge gauge) {
if (gauge.getValue() instanceof Number) {
return ((Number) gauge.getValue()).doubleValue();
} else if (gauge.getValue() instanceof Boolean) {
return ((Boolean) gauge.getValue()) ? 1.0 : 0;
} else {
return -1d;
}
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
protected Ratio getRatio() {
return Ratio.of(sizeGauge.getValue(),
sizeLimitGauge.getValue());
}
});
代码示例来源:origin: signalapp/Signal-Server
private Object evaluateGauge(Gauge gauge) {
try {
return gauge.getValue();
} catch (RuntimeException e) {
logger.warn("Error reading gauge", e);
return "error reading gauge";
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public Map<Integer, Number> getSnapshot() {
// TODO Auto-generated method stub
Number value = gauge.getValue();
Map<Integer, Number> ret = new TreeMap<Integer, Number>();
for (Integer timeKey : windowSeconds) {
ret.put(timeKey, value);
}
ret.put(StatBuckets.ALL_TIME_WINDOW, value);
return ret;
}
代码示例来源:origin: Alluxio/alluxio
private Map<String, Long> getMetricsInternal() {
MetricRegistry metricRegistry = MetricsSystem.METRIC_REGISTRY;
// Get all counters.
Map<String, Counter> counters = metricRegistry.getCounters();
// Only the gauge for cached blocks is retrieved here, other gauges are statistics of
// free/used spaces, those statistics can be gotten via other REST apis.
String blocksCachedProperty =
MetricsSystem.getMetricName(DefaultBlockWorker.Metrics.BLOCKS_CACHED);
@SuppressWarnings("unchecked") Gauge<Integer> blocksCached =
(Gauge<Integer>) metricRegistry.getGauges().get(blocksCachedProperty);
// Get values of the counters and gauges and put them into a metrics map.
SortedMap<String, Long> metrics = new TreeMap<>();
for (Map.Entry<String, Counter> counter : counters.entrySet()) {
metrics.put(counter.getKey(), counter.getValue().getCount());
}
metrics.put(blocksCachedProperty, blocksCached.getValue().longValue());
return metrics;
}
代码示例来源:origin: apache/incubator-gobblin
private void reportGauge(List<Point> points, String prefix, String name, Gauge gauge, long timestamp)
throws IOException {
String metricName = getKey(prefix, name);
points.add(buildMetricAsPoint(metricName, gauge.getValue(), timestamp));
}
代码示例来源:origin: Graylog2/graylog2-server
@GET
@Timed
@RequiresPermissions(RestPermissions.THROUGHPUT_READ)
@ApiOperation(value = "Current throughput of this node in messages per second")
@Produces(MediaType.APPLICATION_JSON)
public Throughput total() {
final SortedMap<String, Gauge> gauges = metricRegistry.getGauges(MetricUtils.filterSingleMetric(
GlobalMetricNames.OUTPUT_THROUGHPUT_RATE));
final Gauge gauge = Iterables.getOnlyElement(gauges.values(), null);
if (gauge == null || !(gauge.getValue() instanceof Number)) {
return Throughput.create(0);
} else {
return Throughput.create(((Number) gauge.getValue()).longValue());
}
}
}
代码示例来源:origin: stagemonitor/stagemonitor
private void reportGauges(Map<MetricName, Gauge> gauges, long timestamp) {
for (Map.Entry<MetricName, Gauge> entry : gauges.entrySet()) {
final String value = getGaugeValueForInfluxDb(entry.getValue().getValue());
if (value != null) {
reportLine(getInfluxDbLineProtocolString(entry.getKey()), value, timestamp);
}
}
}
代码示例来源:origin: alibaba/jstorm
@Override
protected void updateSnapshot(int window) {
double v = (Double) gauge.getValue();
AsmSnapshot snapshot = new AsmGaugeSnapshot().setValue(v)
.setTs(System.currentTimeMillis()).setMetricId(metricId);
snapshots.put(window, snapshot);
}
代码示例来源:origin: stagemonitor/stagemonitor
public static <T> Gauge gauge(T value) {
final Gauge gauge = mock(Gauge.class);
when(gauge.getValue()).thenReturn(value);
return gauge;
}
代码示例来源:origin: azkaban/azkaban
public long getGaugeValue(final String name) {
// Assume that the gauge value can be converted to type long.
return (long) this.registry.getGauges().get(name).getValue();
}
}
代码示例来源:origin: Alluxio/alluxio
private Object getGauge(String name) {
return MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricsSystem.getMetricName(name))
.getValue();
}
}
代码示例来源:origin: Alluxio/alluxio
private Object getGauge(String name) {
return MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricsSystem.getMetricName(name))
.getValue();
}
}
代码示例来源:origin: Alluxio/alluxio
private Object getGauge(String name) {
return MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricsSystem.getClusterMetricName(name))
.getValue();
}
代码示例来源:origin: spotify/helios
private void reportGauge(String name, Gauge gauge) {
final Metric metric = createMetric(name, "gauge")
.value(convert(gauge.getValue()));
send(metric);
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testCommandSuccess() throws InterruptedException {
Command command = new Command();
command.execute();
Thread.sleep(1000);
assertThat((Long) metricRegistry.getGauges().get("hystrix.testGroup.testCommand.countSuccess").getValue(), is(1L));
assertThat((Long) metricRegistry.getGauges().get("hystrix.HystrixThreadPool.threadGroup.totalTaskCount").getValue(), is(1L));
}
代码示例来源:origin: Alluxio/alluxio
private Object getGauge(String metricName, String tagName, String tagValue) {
return MetricsSystem.METRIC_REGISTRY.getGauges()
.get(MetricsSystem
.getClusterMetricName(Metric.getMetricNameWithTags(metricName, tagName, tagValue)))
.getValue();
}
}
代码示例来源:origin: stagemonitor/stagemonitor
private Object getGauge(MetricName gaugeName) {
final Gauge gauge = metricRegistry.getGauges().get(gaugeName);
assertNotNull(gaugeName + " not found in: " + metricRegistry.getGauges(), gauge);
return gauge.getValue();
}
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void testRegisterMBean() throws Exception {
MBeanUtils.registerMBean(MBeanUtils.queryMBean("java.lang:type=ClassLoading"), "LoadedClassCount", name("jvm_class_count").build(), metricRegistry);
final Gauge classLoadingGauge = metricRegistry.getGauges().get(name("jvm_class_count").build());
assertNotNull(classLoadingGauge);
assertTrue(((Integer) classLoadingGauge.getValue()) > 1);
}
}
内容来源于网络,如有侵权,请联系作者删除!