/** * {@inheritDoc} */ @Override public Object getValue(Integer window) { return this.gauge.getValue(); } }
private Object evaluateGauge(Gauge gauge) { try { return gauge.getValue(); } catch (RuntimeException e) { logger.warn("Error reading gauge", e); return "error reading gauge"; } }
@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; }
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; }
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)); }
@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()); } } }
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); } } }
@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); }
public static <T> Gauge gauge(T value) { final Gauge gauge = mock(Gauge.class); when(gauge.getValue()).thenReturn(value); return gauge; }
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(); } }
private Object getGauge(String name) { return MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricsSystem.getMetricName(name)) .getValue(); } }
private Object getGauge(String name) { return MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricsSystem.getMetricName(name)) .getValue(); } }
private Object getGauge(String name) { return MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricsSystem.getClusterMetricName(name)) .getValue(); }
private void reportGauge(String name, Gauge gauge) { final Metric metric = createMetric(name, "gauge") .value(convert(gauge.getValue())); send(metric); }
@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)); }
private Object getGauge(String metricName, String tagName, String tagValue) { return MetricsSystem.METRIC_REGISTRY.getGauges() .get(MetricsSystem .getClusterMetricName(Metric.getMetricNameWithTags(metricName, tagName, tagValue))) .getValue(); } }
private Object getGauge(MetricName gaugeName) { final Gauge gauge = metricRegistry.getGauges().get(gaugeName); assertNotNull(gaugeName + " not found in: " + metricRegistry.getGauges(), gauge); return gauge.getValue(); } }
@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); } }