public void startReporting ( ) { if ( executorService == null ) { throw new IllegalStateException ( "MonitoringServiceClient already shutdown" ) ; } if ( scheduledFuture != null ) { logger . error ( "only one performance reporting thread can be started" ) ; return ; } Runnable performanceReporterCallable = new Runnable ( ) { @ Override public void run ( ) { try { // only send a report if the bounce proxy is initialized if ( bounceProxyLifecycleMonitor . isInitialized ( ) ) { // Don't do any retries here. If we miss on performance // report, we'll just wait for the next loop. sendPerformanceReportAsHttpRequest ( ) ; } } catch ( Exception e ) { logger . error ( "Uncaught exception in reportPerformance." , e ) ; } } } ; scheduledFuture = executorService . scheduleWithFixedDelay ( performanceReporterCallable , performanceReportingFrequencyMs , performanceReportingFrequencyMs , TimeUnit . MILLISECONDS ) ; }
Starts a reporting loop that sends performance measures to the monitoring service in a certain frequency .