use of com.microsoft.applicationinsights.alerting.alert.AlertBreach in project ApplicationInsights-Java by microsoft.
the class ProfilerServiceTest method getJfrDaemon.
private JfrProfiler getJfrDaemon(AtomicBoolean profileInvoked) throws MalformedURLException {
return new JfrProfiler(new ServiceProfilerServiceConfig(1, 2, 3, new URL("http://localhost"), null, null, LocalFileSystemUtils.getTempDir())) {
@Override
protected void profileAndUpload(AlertBreach alertBreach, Duration duration) {
profileInvoked.set(true);
Recording recording = Mockito.mock(Recording.class);
uploadNewRecording(alertBreach, Instant.now()).accept(recording);
}
@Override
protected File createJfrFile(Recording recording, Instant recordingStart, Instant recordingEnd) throws IOException {
return File.createTempFile("jfrFile", jfrExtension);
}
};
}
use of com.microsoft.applicationinsights.alerting.alert.AlertBreach in project ApplicationInsights-Java by microsoft.
the class AlertingSubsystemTest method manualAlertDoesNotTriggerAfterExpired.
@Test
void manualAlertDoesNotTriggerAfterExpired() {
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().minus(100, ChronoUnit.SECONDS), 120, "a-settings-moniker")));
assertThat(called.get()).isNull();
}
use of com.microsoft.applicationinsights.alerting.alert.AlertBreach in project ApplicationInsights-Java by microsoft.
the class JfrProfiler method performPeriodicProfile.
/**
* Action to be performed on a periodic profile request.
*/
public void performPeriodicProfile() {
LOGGER.info("Received periodic profile request");
profileAndUpload(new AlertBreach(AlertMetricType.PERIODIC, 0, periodicConfig), Duration.ofSeconds(periodicConfig.getProfileDuration()));
}
use of com.microsoft.applicationinsights.alerting.alert.AlertBreach in project ApplicationInsights-Java by microsoft.
the class AlertingSubsystem method evaluateManualTrigger.
/**
* Determine if a manual alert has been requested.
*/
private void evaluateManualTrigger(AlertingConfiguration alertConfig) {
CollectionPlanConfiguration config = alertConfig.getCollectionPlanConfiguration();
boolean shouldTrigger = config.isSingle() && config.getMode() == EngineMode.immediate && ZonedDateTime.now().isBefore(config.getExpiration()) && !manualTriggersExecuted.contains(config.getSettingsMoniker());
if (shouldTrigger) {
manualTriggersExecuted.add(config.getSettingsMoniker());
AlertBreach alertBreach = new AlertBreach(AlertMetricType.MANUAL, 0.0, new AlertConfigurationBuilder().setType(AlertMetricType.MANUAL).setEnabled(true).setProfileDuration(config.getImmediateProfilingDuration()).setThreshold(0.0f).setCooldown(0).createAlertConfiguration());
alertHandler.accept(alertBreach);
}
}
use of com.microsoft.applicationinsights.alerting.alert.AlertBreach in project ApplicationInsights-Java by microsoft.
the class AlertPipelineTrigger method accept.
@Override
public void accept(Double telemetry) {
if (alertConfig.isEnabled() && telemetry > alertConfig.getThreshold()) {
if (isOffCooldown()) {
lastAlertTime = ZonedDateTime.now();
action.accept(new AlertBreach(alertConfig.getType(), telemetry, alertConfig));
}
}
}
Aggregations