use of com.netflix.servo.monitor.Counter in project incubator-servicecomb-java-chassis by apache.
the class TestMonitorManager method checkRegisterMonitorWithoutAnyTags.
@Test
public void checkRegisterMonitorWithoutAnyTags() {
Counter counter = MonitorManager.getInstance().getCounter("MonitorWithoutAnyTag");
counter.increment(999);
Assert.assertTrue(MonitorManager.getInstance().measure().containsKey("MonitorWithoutAnyTag"));
Assert.assertEquals(999, MonitorManager.getInstance().measure().get("MonitorWithoutAnyTag"), 0);
}
use of com.netflix.servo.monitor.Counter in project incubator-servicecomb-java-chassis by apache.
the class MonitorManager method getCounter.
public Counter getCounter(String name, String... tags) {
validateMonitorNameAndTags(name, tags);
return counters.computeIfAbsent(getMonitorKey(name, tags), f -> {
Counter counter = new BasicCounter(getConfig(name, tags));
basicMonitorRegistry.register(counter);
return counter;
});
}
use of com.netflix.servo.monitor.Counter in project tutorials by eugenp.
the class MetricTypeTest method givenBasicCounter_whenManipulate_thenCountValid.
@Test
public void givenBasicCounter_whenManipulate_thenCountValid() {
Counter counter = new BasicCounter(MonitorConfig.builder("test").build());
assertEquals("counter should start with 0", 0, counter.getValue().intValue());
counter.increment();
assertEquals("counter should have increased by 1", 1, counter.getValue().intValue());
counter.increment(-1);
assertEquals("counter should have decreased by 1", 0, counter.getValue().intValue());
}
use of com.netflix.servo.monitor.Counter in project tutorials by eugenp.
the class MetricTypeTest method givenStepCounter_whenManipulate_thenRateValid.
@Ignore
@Test
public void givenStepCounter_whenManipulate_thenRateValid() throws Exception {
System.setProperty("servo.pollers", "1000");
Counter counter = new StepCounter(MonitorConfig.builder("test").build());
assertEquals("counter should start with rate 0.0", 0.0, counter.getValue());
counter.increment();
SECONDS.sleep(1);
assertEquals("counter rate should have increased to 1.0", 1.0, counter.getValue());
}
use of com.netflix.servo.monitor.Counter in project tutorials by eugenp.
the class MetricTypeTest method givenPeakRateCounter_whenManipulate_thenPeakRateReturn.
@Test
public void givenPeakRateCounter_whenManipulate_thenPeakRateReturn() throws Exception {
Counter counter = new PeakRateCounter(MonitorConfig.builder("test").build());
assertEquals("counter should start with 0", 0, counter.getValue().intValue());
counter.increment();
SECONDS.sleep(1);
counter.increment();
counter.increment();
assertEquals("peak rate should have be 2", 2, counter.getValue().intValue());
}
Aggregations