private static void doStartMonitoring() { if (started) { return; } if (measurementSession.isInitialized()) { logger.info("Measurement Session is initialized: " + measurementSession); try { start(); } catch (RuntimeException e) { logger.warn("Error while trying to start monitoring. (this exception is ignored)", e); } } else { logger.debug("Measurement Session is not initialized: {}", measurementSession); logger.debug("make sure the properties 'stagemonitor.instanceName' and 'stagemonitor.applicationName' " + "are set and stagemonitor.properties is available in the classpath"); } }
@Test public void testStartMonitoring() throws Exception { when(corePlugin.isStagemonitorActive()).thenReturn(true); Stagemonitor.setConfiguration(configuration); Stagemonitor.reset(); final MeasurementSession measurementSession = new MeasurementSession("StagemonitorTest", "testHost", "testInstance"); Stagemonitor.reset(measurementSession); assertTrue(Stagemonitor.isStarted()); assertTrue(Stagemonitor.getMeasurementSession().isInitialized()); assertSame(measurementSession, Stagemonitor.getMeasurementSession()); assertThat(healthCheckRegistry.runHealthCheck("TestPlugin").isHealthy()).isTrue(); assertThat(healthCheckRegistry.runHealthCheck("TestExceptionPlugin").isHealthy()).isFalse(); }
@Test public void testStartMonitoringNotActive() throws Exception { when(corePlugin.isStagemonitorActive()).thenReturn(false); final MeasurementSession measurementSession = new MeasurementSession("StagemonitorTest", "testHost", "testInstance"); Stagemonitor.reset(measurementSession); assertTrue(Stagemonitor.isDisabled()); assertFalse(Stagemonitor.isStarted()); assertTrue(Stagemonitor.getMeasurementSession().isInitialized()); assertThat(healthCheckRegistry.getNames()).doesNotContain("TestPlugin", "TestExceptionPlugin"); }