Search in sources :

Example 1 with ServiceProfilerIndex

use of com.microsoft.applicationinsights.profiler.uploader.ServiceProfilerIndex in project ApplicationInsights-Java by microsoft.

the class ServiceProfilerUploader method uploadJfrFile.

/**
 * Upload a given JFR file and return associated metadata of the uploaded profile.
 */
public Mono<UploadResult> uploadJfrFile(String triggerName, long timestamp, File file, double cpuUsage, double memoryUsage) {
    String appId = appIdSupplier.get();
    if (appId == null || appId.isEmpty()) {
        LOGGER.error("Failed to upload due to lack of appId");
        return Mono.error(new UploadFailedException("Failed to upload due to lack of appId"));
    }
    UUID profileId = UUID.randomUUID();
    UploadContext uploadContext = new UploadContext(machineName, UUID.fromString(appId), timestamp, file, profileId);
    // upload trace to service profiler
    return uploadTrace(uploadContext).map(done -> {
        // return associated profile metadata
        String fileId = createId(9);
        String formattedTimestamp = TimestampContract.padNanos(done.getTimeStamp());
        return new UploadResult(new ServiceProfilerIndex(triggerName, fileId, done.getStampId(), UUID.fromString(appId), formattedTimestamp, uploadContext.getMachineName(), OsPlatformProvider.getOsPlatformDescription(), processId, "Profile", profileId.toString(), "jfr", cpuUsage, memoryUsage));
    });
}
Also used : ServiceProfilerIndex(com.microsoft.applicationinsights.profiler.uploader.ServiceProfilerIndex) UploadResult(com.microsoft.applicationinsights.profiler.uploader.UploadResult) UUID(java.util.UUID) UploadContext(com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadContext)

Aggregations

ServiceProfilerIndex (com.microsoft.applicationinsights.profiler.uploader.ServiceProfilerIndex)1 UploadResult (com.microsoft.applicationinsights.profiler.uploader.UploadResult)1 UploadContext (com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadContext)1 UUID (java.util.UUID)1