Search in sources :

Example 6 with ServiceProfilerClientV2

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();
}
Also used : ServiceProfilerClientV2(com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2) BlobUploadFromFileOptions(com.azure.storage.blob.options.BlobUploadFromFileOptions) UUID(java.util.UUID) File(java.io.File) UploadContext(com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadContext) Test(org.junit.jupiter.api.Test)

Example 7 with ServiceProfilerClientV2

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);
}
Also used : ServiceProfilerClientV2(com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2) ProfilerFrontendClientV2(com.microsoft.applicationinsights.serviceprofilerapi.client.ProfilerFrontendClientV2) ServiceProfilerUploader(com.microsoft.applicationinsights.serviceprofilerapi.upload.ServiceProfilerUploader) JfrProfiler(com.microsoft.applicationinsights.serviceprofilerapi.profiler.JfrProfiler)

Example 8 with ServiceProfilerClientV2

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();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ServiceProfilerClientV2(com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2) UUID(java.util.UUID) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ServiceProfilerClientV2 (com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2)8 Test (org.junit.jupiter.api.Test)5 File (java.io.File)3 UUID (java.util.UUID)3 ProfilerConfiguration (com.microsoft.applicationinsights.profiler.ProfilerConfiguration)2 UploadContext (com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadContext)2 JfrProfiler (com.microsoft.applicationinsights.serviceprofilerapi.profiler.JfrProfiler)2 ServiceProfilerUploader (com.microsoft.applicationinsights.serviceprofilerapi.upload.ServiceProfilerUploader)2 Date (java.util.Date)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 BlobUploadFromFileOptions (com.azure.storage.blob.options.BlobUploadFromFileOptions)1 MonitorDomain (com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorDomain)1 TelemetryEventData (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryEventData)1 TelemetryItem (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem)1 TelemetryClient (com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient)1 AlertingSubsystem (com.microsoft.applicationinsights.alerting.AlertingSubsystem)1 ProfilerService (com.microsoft.applicationinsights.profiler.ProfilerService)1 ProfilerServiceFactory (com.microsoft.applicationinsights.profiler.ProfilerServiceFactory)1