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);
   }
 }
Ejemplo n.º 2
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();
    }
  }
Ejemplo n.º 3
0
 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());
 }