コード例 #1
0
 public synchronized void notifyConvertorUpdate(LoggerData updatedLoggerData) {
   Gauge gauge = gauges.get(updatedLoggerData);
   if (gauge != null) {
     gauge.resetValue();
     gauge.refreshTitle();
   }
 }
コード例 #2
0
 public synchronized void handleDataUpdate(Response response) {
   for (LoggerData loggerData : response.getData()) {
     Gauge gauge = gauges.get(loggerData);
     if (gauge != null) {
       gauge.updateValue(response.getDataValue(loggerData));
     }
   }
 }
コード例 #3
0
 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);
   }
 }
コード例 #4
0
 @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();
   }
 }
コード例 #5
0
  @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();
    }
  }
コード例 #6
0
 private <T> Gauge gauge(T value) {
   final Gauge gauge = mock(Gauge.class);
   when(gauge.getValue()).thenReturn(value);
   return gauge;
 }
コード例 #7
0
 @Override
 public void processGauge(MetricName name, Gauge<?> gauge, PrintStream stream) {
   stream.printf(locale, "    value = %s\n", gauge.getValue());
 }
コード例 #8
0
 public synchronized void reset() {
   for (Gauge gauge : gauges.values()) {
     gauge.resetValue();
   }
 }