Search in sources :

Example 1 with JfrUploadService

use of com.microsoft.applicationinsights.serviceprofilerapi.profiler.JfrUploadService in project ApplicationInsights-Java by microsoft.

the class JfrProfilerService method initialize.

public Future<ProfilerService> initialize() {
    CompletableFuture<ProfilerService> result = new CompletableFuture<>();
    if (initialised) {
        result.complete(this);
        return result;
    }
    LOGGER.warn("INITIALISING JFR PROFILING SUBSYSTEM THIS FEATURE IS IN BETA");
    initialised = true;
    profileHandler = new JfrUploadService(serviceProfilerUploader, appIdSupplier, uploadCompleteObserver);
    serviceProfilerExecutorService.submit(() -> {
        try {
            if (!initialiseProfiler()) {
                result.completeExceptionally(new RuntimeException("Unable to obtain JFR connection, this may indicate that your JVM does not have JFR enabled. JFR profiling system will shutdown"));
                return;
            }
            // Monitor service remains alive permanently due to scheduling an periodic config pull
            ServiceProfilerConfigMonitorService.createServiceProfilerConfigService(serviceProfilerExecutorService, serviceProfilerClient, Arrays.asList(profilerConfigurationHandler, profiler), config);
            result.complete(this);
        } catch (RuntimeException e) {
            LOGGER.error("Failed to initialise alert service", e);
        } catch (Error e) {
            LOGGER.error("Failed to initialise alert service", e);
            throw e;
        }
    });
    return result;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JfrUploadService(com.microsoft.applicationinsights.serviceprofilerapi.profiler.JfrUploadService) ProfilerService(com.microsoft.applicationinsights.profiler.ProfilerService)

Aggregations

ProfilerService (com.microsoft.applicationinsights.profiler.ProfilerService)1 JfrUploadService (com.microsoft.applicationinsights.serviceprofilerapi.profiler.JfrUploadService)1 CompletableFuture (java.util.concurrent.CompletableFuture)1