com.netflix.servo.monitor.Counter Java Examples
The following examples show how to use
com.netflix.servo.monitor.Counter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricTypeManualTest.java From tutorials with MIT License | 6 votes |
@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()); }
Example #2
Source File: MetricTypeManualTest.java From tutorials with MIT License | 6 votes |
@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()); }
Example #3
Source File: AtlasObserverLiveTest.java From tutorials with MIT License | 6 votes |
@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")); }
Example #4
Source File: MetricTypeManualTest.java From tutorials with MIT License | 5 votes |
@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()); }
Example #5
Source File: MetricTypeManualTest.java From tutorials with MIT License | 5 votes |
@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()); }
Example #6
Source File: BaseLoadBalancer.java From ribbon with Apache License 2.0 | 4 votes |
private final Counter createCounter() { return Monitors.newCounter("LoadBalancer_ChooseServer"); }