Java Code Examples for com.netflix.servo.monitor.Monitors#newCounter()

The following examples show how to use com.netflix.servo.monitor.Monitors#newCounter() . 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: PrimeConnections.java    From ribbon with Apache License 2.0 6 votes vote down vote up
private void setUp(String name, int maxRetries, 
        long maxTotalTimeToPrimeConnections, String primeConnectionsURI, float primeRatio) {        
    this.name = name;
    this.maxRetries = maxRetries;
    this.maxTotalTimeToPrimeConnections = maxTotalTimeToPrimeConnections;
    this.primeConnectionsURIPath = primeConnectionsURI;        
    this.primeRatio = primeRatio;
    executorService = new ThreadPoolExecutor(1 /* minimum */,
            maxExecutorThreads /* max threads */,
            executorThreadTimeout /*
                                   * timeout - same property as create
                                   * timeout
                                   */, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>()
            /* Bounded queue with FIFO- bounded to max tasks */,
            new ASyncPrimeConnectionsThreadFactory(name) /*
                                                          * So we can give
                                                          * our Thread a
                                                          * name
                                                          */
    );        
    totalCounter = Monitors.newCounter(name + "_PrimeConnection_TotalCounter");
    successCounter = Monitors.newCounter(name + "_PrimeConnection_SuccessCounter");
    initialPrimeTimer = Monitors.newTimer(name + "_initialPrimeConnectionsTimer", TimeUnit.MILLISECONDS);
    Monitors.registerObject(name + "_PrimeConnection", this);
}
 
Example 2
Source File: NamedConnectionPool.java    From ribbon with Apache License 2.0 5 votes vote down vote up
void initMonitors(String name) {
    Preconditions.checkNotNull(name);
    freeEntryCounter = Monitors.newCounter(name + "_Reuse");
    createEntryCounter = Monitors.newCounter(name + "_CreateNew");
    requestCounter = Monitors.newCounter(name + "_Request");
    releaseCounter = Monitors.newCounter(name + "_Release");
    deleteCounter = Monitors.newCounter(name + "_Delete");
    requestTimer = Monitors.newTimer(name + "_RequestConnectionTimer", TimeUnit.MILLISECONDS);
    creationTimer = Monitors.newTimer(name + "_CreateConnectionTimer", TimeUnit.MILLISECONDS);
    this.name = name;
    Monitors.registerObject(name, this);
}
 
Example 3
Source File: ZoneAffinityServerListFilter.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig niwsClientConfig) {
    zoneAffinity = niwsClientConfig.getOrDefault(CommonClientConfigKey.EnableZoneAffinity);
    zoneExclusive = niwsClientConfig.getOrDefault(CommonClientConfigKey.EnableZoneExclusivity);
    zone = niwsClientConfig.getGlobalProperty(ZONE).getOrDefault();
    zoneAffinityPredicate = new ZoneAffinityPredicate(zone);

    activeReqeustsPerServerThreshold = niwsClientConfig.getDynamicProperty(MAX_LOAD_PER_SERVER);
    blackOutServerPercentageThreshold = niwsClientConfig.getDynamicProperty(MAX_BLACKOUT_SERVER_PERCENTAGE);
    availableServersThreshold = niwsClientConfig.getDynamicProperty(MIN_AVAILABLE_SERVERS);

    overrideCounter = Monitors.newCounter("ZoneAffinity_OverrideCounter");

    Monitors.registerObject("NIWSServerListFilter_" + niwsClientConfig.getClientName());
}
 
Example 4
Source File: ZoneStats.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public ZoneStats(String name, String zone, LoadBalancerStats loadBalancerStats) {
    this.zone = zone;
    this.loadBalancerStats = loadBalancerStats;
    monitorId = name + ":" + zone;  
    counter = Monitors.newCounter(PREFIX + name + "_" + zone + "_Counter");
    Monitors.registerObject(monitorId, this);
}
 
Example 5
Source File: MetricTypeManualTest.java    From tutorials with MIT License 5 votes vote down vote up
@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 6
Source File: BaseLoadBalancer.java    From ribbon with Apache License 2.0 4 votes vote down vote up
private final Counter createCounter() {
    return Monitors.newCounter("LoadBalancer_ChooseServer");
}