com.netflix.servo.monitor.BasicCounter Java Examples

The following examples show how to use com.netflix.servo.monitor.BasicCounter. 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 vote down vote up
@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: AtlasObserverLiveTest.java    From tutorials with MIT License 6 votes vote down vote up
@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 #3
Source File: DynoOPMonitor.java    From dyno with Apache License 2.0 5 votes vote down vote up
private BasicCounter getNewCounter(String metricName, String opName, String compressionEnabled) {
    MonitorConfig config = MonitorConfig.builder(metricName)
            .withTag(new BasicTag("dyno_op", opName))
            .withTag(new BasicTag("compression_enabled", compressionEnabled))
            .build();
    return new BasicCounter(config);
}
 
Example #4
Source File: DynoJedisPipelineMonitor.java    From dyno with Apache License 2.0 5 votes vote down vote up
private BasicCounter getOrCreateCounter(String opName) {

        BasicCounter counter = counterMap.get(opName);
        if (counter != null) {
            return counter;
        }
        counter = getNewPipelineCounter(opName);
        BasicCounter prevCounter = counterMap.putIfAbsent(opName, counter);
        if (prevCounter != null) {
            return prevCounter;
        }
        DefaultMonitorRegistry.getInstance().register(counter);
        return counter;
    }
 
Example #5
Source File: DynoJedisPipelineMonitor.java    From dyno with Apache License 2.0 5 votes vote down vote up
private BasicCounter getNewPipelineCounter(String opName) {

        String metricName = "Dyno__" + appName + "__PL__" + opName;
        MonitorConfig config = MonitorConfig.builder(metricName)
                .withTag(new BasicTag("dyno_pl_op", opName))
                .build();
        return new BasicCounter(config);
    }
 
Example #6
Source File: Counter.java    From s2g-zuul with MIT License 4 votes vote down vote up
@Override
public void increment(String name) {
    BasicCounter counter = getCounter(name);
    counter.increment();
}
 
Example #7
Source File: Meter.java    From suro with Apache License 2.0 4 votes vote down vote up
public Meter(MonitorConfig config) {
    counter = new BasicCounter(config);
    startTime = System.currentTimeMillis() - 1; // to prevent divided by 0
}