public synchronized void notifyConvertorUpdate(LoggerData updatedLoggerData) { Gauge gauge = gauges.get(updatedLoggerData); if (gauge != null) { gauge.resetValue(); gauge.refreshTitle(); } }
public synchronized void handleDataUpdate(Response response) { for (LoggerData loggerData : response.getData()) { Gauge gauge = gauges.get(loggerData); if (gauge != null) { gauge.updateValue(response.getDataValue(loggerData)); } } }
public void addGauge(String name, Gauge gauge) { final Object value = gauge.getValue(); if (value instanceof Number) { final Number number = (Number) value; if (!checkNumber(name, number)) { return; } addGaugeMeasurement(name, number); } }
@Override public void processGauge(MetricName name, Gauge<?> gauge, Long epoch) { Object v = gauge.value(); EventDSL e = newEvent().service(service(name)).time(epoch); if (v instanceof Integer) { e.metric((Integer) v).send(); } else if (v instanceof Long) { e.metric((Long) v).send(); } else if (v instanceof Double) { e.metric((Double) v).send(); } else if (v instanceof Float) { e.metric((Float) v).send(); } else if (v instanceof Number) { e.metric(((Number) v).floatValue()).send(); } }
@Test public void testGauge() { System.out.println("******************************* GAUGE *******************************"); gauge = new Gauge<Integer>() { @Override public Integer getValue() { return count++; } }; registry.register("gauge", gauge); try { for (int i = 0; i < ITER_COUNT; i++) { gauge.getValue(); Thread.sleep(SLEEP_MS); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } }
private <T> Gauge gauge(T value) { final Gauge gauge = mock(Gauge.class); when(gauge.getValue()).thenReturn(value); return gauge; }
@Override public void processGauge(MetricName name, Gauge<?> gauge, PrintStream stream) { stream.printf(locale, " value = %s\n", gauge.getValue()); }
public synchronized void reset() { for (Gauge gauge : gauges.values()) { gauge.resetValue(); } }