Search in sources :

Example 6 with CollectionPlanConfiguration

use of com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration in project ApplicationInsights-Java by microsoft.

the class AlertingSubsystemTest method manualAlertWorks.

@Test
void manualAlertWorks() {
    AtomicReference<AlertBreach> called = new AtomicReference<>();
    Consumer<AlertBreach> consumer = called::set;
    AlertingSubsystem service = AlertingSubsystem.create(consumer, Executors.newSingleThreadExecutor());
    service.updateConfiguration(new AlertingConfiguration(new AlertConfiguration(AlertMetricType.CPU, true, 80, 30, 14400), new AlertConfiguration(AlertMetricType.MEMORY, true, 20, 120, 14400), new DefaultConfiguration(true, 5, 120), new CollectionPlanConfiguration(true, EngineMode.immediate, ZonedDateTime.now().plus(100, ChronoUnit.SECONDS), 120, "a-settings-moniker")));
    assertThat(called.get().getType()).isEqualTo(AlertMetricType.MANUAL);
}
Also used : AlertBreach(com.microsoft.applicationinsights.alerting.alert.AlertBreach) AtomicReference(java.util.concurrent.atomic.AtomicReference) DefaultConfiguration(com.microsoft.applicationinsights.alerting.config.DefaultConfiguration) CollectionPlanConfiguration(com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration) AlertConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfiguration) AlertingConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

CollectionPlanConfiguration (com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration)6 AlertingConfiguration (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration)5 DefaultConfiguration (com.microsoft.applicationinsights.alerting.config.DefaultConfiguration)5 AlertConfiguration (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfiguration)4 AlertBreach (com.microsoft.applicationinsights.alerting.alert.AlertBreach)3 Test (org.junit.jupiter.api.Test)3 AlertConfigurationBuilder (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfigurationBuilder)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2