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));
});
}
Aggregations