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

The following examples show how to use com.netflix.servo.monitor.Monitors#newTimer() . 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: NFHttpClient.java    From ribbon with Apache License 2.0 5 votes vote down vote up
void init(IClientConfig config, boolean registerMonitor) {
	HttpParams params = getParams();

	HttpProtocolParams.setContentCharset(params, "UTF-8");  
	params.setParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME, 
			ThreadSafeClientConnManager.class.getName());
	HttpClientParams.setRedirecting(params, config.get(CommonClientConfigKey.FollowRedirects, true));
	// set up default headers
	List<Header> defaultHeaders = new ArrayList<Header>();
	defaultHeaders.add(new BasicHeader("Netflix.NFHttpClient.Version", "1.0"));
	defaultHeaders.add(new BasicHeader("X-netflix-httpclientname", name));
	params.setParameter(ClientPNames.DEFAULT_HEADERS, defaultHeaders);

	connPoolCleaner = new ConnectionPoolCleaner(name, this.getConnectionManager(), connectionPoolCleanUpScheduler);

	this.retriesProperty = config.getGlobalProperty(RETRIES.format(name));

	this.sleepTimeFactorMsProperty = config.getGlobalProperty(SLEEP_TIME_FACTOR_MS.format(name));
	setHttpRequestRetryHandler(
			new NFHttpMethodRetryHandler(this.name, this.retriesProperty.getOrDefault(), false,
					this.sleepTimeFactorMsProperty.getOrDefault()));
    tracer = Monitors.newTimer(EXECUTE_TRACER + "-" + name, TimeUnit.MILLISECONDS);
    if (registerMonitor) {
           Monitors.registerObject(name, this);
    }
    maxTotalConnectionProperty = config.getDynamicProperty(CommonClientConfigKey.MaxTotalHttpConnections);
    maxTotalConnectionProperty.onChange(newValue ->
    	((ThreadSafeClientConnManager) getConnectionManager()).setMaxTotal(newValue)
    );

    maxConnectionPerHostProperty = config.getDynamicProperty(CommonClientConfigKey.MaxHttpConnectionsPerHost);
    maxConnectionPerHostProperty.onChange(newValue ->
		((ThreadSafeClientConnManager) getConnectionManager()).setDefaultMaxPerRoute(newValue)
       );

	connIdleEvictTimeMilliSeconds = config.getGlobalProperty(CONN_IDLE_EVICT_TIME_MILLIS.format(name));
}
 
Example 3
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 4
Source File: LoadBalancerContext.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public Timer getExecuteTracer() {
    if (tracer == null) {
        synchronized(this) {
            if (tracer == null) {
                tracer = Monitors.newTimer(clientName + "_LoadBalancerExecutionTimer", TimeUnit.MILLISECONDS);                    
            }
        }
    } 
    return tracer;        
}