Search in sources :

Example 1 with ServiceProfilerConfigMonitorService

use of com.microsoft.applicationinsights.serviceprofilerapi.config.ServiceProfilerConfigMonitorService in project ApplicationInsights-Java by microsoft.

the class ServiceProfilerConfigMonitorServiceTest method pullsConfig.

@Test
void pullsConfig() throws IOException, URISyntaxException {
    AtomicReference<Runnable> job = new AtomicReference<>();
    ScheduledExecutorService executorService = mockScheduledExecutorService(job::set);
    ServiceProfilerClientV2 serviceProfilerClient = mockServiceProfilerClient();
    ServiceProfilerConfigMonitorService serviceMonitor = new ServiceProfilerConfigMonitorService(executorService, 100, serviceProfilerClient);
    AtomicReference<ProfilerConfiguration> config = new AtomicReference<>();
    serviceMonitor.initialize(Collections.singletonList(config::set));
    assertThat(job.get()).isNotNull();
    job.get().run();
    Mockito.verify(serviceProfilerClient, times(1)).getSettings(any(Date.class));
    assertThat(config.get()).isNotNull();
    assertThat(config.get().getCollectionPlan()).isEqualTo("--single --mode immediate --immediate-profiling-duration 120  --expiration 5249157885138288517 --settings-moniker a-settings-moniker");
    assertThat(config.get().getCpuTriggerConfiguration()).isEqualTo("--cpu-trigger-enabled true --cpu-threshold 80 --cpu-trigger-profilingDuration 30 --cpu-trigger-cooldown 14400");
    assertThat(config.get().getDefaultConfiguration()).isEqualTo("--sampling-enabled true --sampling-rate 5 --sampling-profiling-duration 120");
    assertThat(config.get().getMemoryTriggerConfiguration()).isEqualTo("--memory-trigger-enabled true --memory-threshold 20 --memory-trigger-profilingDuration 120 --memory-trigger-cooldown 14400");
}
Also used : ServiceProfilerConfigMonitorService(com.microsoft.applicationinsights.serviceprofilerapi.config.ServiceProfilerConfigMonitorService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ServiceProfilerClientV2(com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2) ProfilerConfiguration(com.microsoft.applicationinsights.profiler.ProfilerConfiguration) AtomicReference(java.util.concurrent.atomic.AtomicReference) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

ProfilerConfiguration (com.microsoft.applicationinsights.profiler.ProfilerConfiguration)1 ServiceProfilerClientV2 (com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2)1 ServiceProfilerConfigMonitorService (com.microsoft.applicationinsights.serviceprofilerapi.config.ServiceProfilerConfigMonitorService)1 Date (java.util.Date)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.jupiter.api.Test)1