use of com.microsoft.gcmonitor.GcEventConsumer in project ApplicationInsights-Java by microsoft.
the class GcEventMonitorTest method endToEndAlertIsTriggered.
@Test
void endToEndAlertIsTriggered() throws ExecutionException, InterruptedException, TimeoutException {
CompletableFuture<AlertBreach> alertFuture = new CompletableFuture<>();
AlertingSubsystem alertingSubsystem = getAlertingSubsystem(alertFuture);
GcMonitorFactory factory = new GcMonitorFactory() {
@Override
public MemoryManagement monitorSelf(ExecutorService executorService, GcEventConsumer consumer) {
consumer.accept(mockGcEvent());
return null;
}
@Override
public MemoryManagement monitor(MBeanServerConnection connection, ExecutorService executorService, GcEventConsumer consumer) {
return null;
}
};
GcEventMonitor.init(alertingSubsystem, TelemetryClient.createForTest(), Executors.newSingleThreadExecutor(), new GcEventMonitor.GcEventMonitorConfiguration(GcReportingLevel.NONE), factory);
AlertBreach alert = alertFuture.get(10, TimeUnit.SECONDS);
assertThat(alert.getAlertValue()).isEqualTo(90.0);
}
Aggregations