use of com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2 in project ApplicationInsights-Java by microsoft.
the class ServiceProfilerUploaderTest method roleNameIsCorrectlyAddedToMetaData.
@Test
void roleNameIsCorrectlyAddedToMetaData() throws IOException {
ServiceProfilerClientV2 serviceProfilerClient = stubServiceProfilerClient();
File tmpFile = createFakeJfrFile();
UUID appId = UUID.randomUUID();
BlobUploadFromFileOptions blobOptions = new ServiceProfilerUploader(serviceProfilerClient, "a-machine-name", "a-process-id", appId::toString, "a-role-name").createBlockBlobOptions(tmpFile, new UploadContext("a-machine-name", UUID.randomUUID(), 1, tmpFile, UUID.randomUUID()));
// Role name is set correctly
assertThat(blobOptions.getMetadata().get(BlobMetadataConstants.ROLE_NAME_META_NAME)).isEqualTo("a-role-name");
blobOptions = new ServiceProfilerUploader(serviceProfilerClient, "a-machine-name", "a-process-id", appId::toString, null).createBlockBlobOptions(tmpFile, new UploadContext("a-machine-name", UUID.randomUUID(), 1, tmpFile, UUID.randomUUID()));
// Null role name tag is not added
assertThat(blobOptions.getMetadata().get(BlobMetadataConstants.ROLE_NAME_META_NAME)).isNull();
}
use of com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2 in project ApplicationInsights-Java by microsoft.
the class JfrProfilerServiceFactory method initialize.
@Override
public synchronized Future<ProfilerService> initialize(Supplier<String> appIdSupplier, UploadCompleteHandler uploadCompleteObserver, ProfilerConfigurationHandler profilerConfigurationHandler, String processId, ServiceProfilerServiceConfig config, String machineName, String instrumentationKey, HttpPipeline httpPipeline, ScheduledExecutorService serviceProfilerExecutorService, String userAgent, String roleName) {
if (instance == null) {
ServiceProfilerClientV2 serviceProfilerClient = new ProfilerFrontendClientV2(config.getServiceProfilerFrontEndPoint(), instrumentationKey, httpPipeline, userAgent);
ServiceProfilerUploader uploader = new ServiceProfilerUploader(serviceProfilerClient, machineName, processId, appIdSupplier, roleName);
instance = new JfrProfilerService(appIdSupplier, config, new JfrProfiler(config), profilerConfigurationHandler, uploadCompleteObserver, serviceProfilerClient, uploader, serviceProfilerExecutorService);
return instance.initialize();
}
return CompletableFuture.completedFuture(instance);
}
use of com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2 in project ApplicationInsights-Java by microsoft.
the class ServiceProfilerUploaderTest method uploadWithoutFileThrows.
@Test
void uploadWithoutFileThrows() {
ServiceProfilerClientV2 serviceProfilerClient = stubServiceProfilerClient();
UUID appId = UUID.randomUUID();
ServiceProfilerUploader serviceProfilerUploader = new ServiceProfilerUploader(serviceProfilerClient, "a-machine-name", "a-process-id", appId::toString, "a-role-name");
AtomicBoolean threw = new AtomicBoolean(false);
serviceProfilerUploader.uploadJfrFile("a-trigger", 321, new File("not-a-file"), 0.0, 0.0).subscribe(result -> {
}, e -> threw.set(true));
assertThat(threw.get()).isTrue();
}
Aggregations