use of com.netflix.servo.monitor.Counter in project incubator-servicecomb-java-chassis by apache.
the class MonitorManager method getCounter.
public Counter getCounter(Function<MonitorConfig, Counter> function, String name, String... tags) {
validateMonitorNameAndTags(name, tags);
return counters.computeIfAbsent(getMonitorKey(name, tags), f -> {
Counter counter = function.apply(getConfig(name, tags));
basicMonitorRegistry.register(counter);
return counter;
});
}
use of com.netflix.servo.monitor.Counter in project tutorials by eugenp.
the class AtlasObserverLiveTest method givenAtlasAndCounter_whenRegister_thenPublishedToAtlas.
@Test
public void givenAtlasAndCounter_whenRegister_thenPublishedToAtlas() throws Exception {
Counter counter = new BasicCounter(MonitorConfig.builder("test").withTag("servo", "counter").build());
DefaultMonitorRegistry.getInstance().register(counter);
assertThat(atlasValuesOfTag("servo"), not(containsString("counter")));
for (int i = 0; i < 3; i++) {
counter.increment(RandomUtils.nextInt(10));
SECONDS.sleep(1);
counter.increment(-1 * RandomUtils.nextInt(10));
SECONDS.sleep(1);
}
assertThat(atlasValuesOfTag("servo"), containsString("counter"));
}
use of com.netflix.servo.monitor.Counter in project tutorials by eugenp.
the class MetricTypeTest method givenDefaultCounter_whenManipulate_thenCountValid.
@Test
public void givenDefaultCounter_whenManipulate_thenCountValid() {
Counter counter = Monitors.newCounter("test");
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());
}
Aggregations