@Test public void testSpringCloud_multipleConfigUrls() throws IOException { when(corePlugin.getRemotePropertiesConfigUrls()).thenReturn( Arrays.asList(new URL("http://localhost/config1"), new URL("http://localhost/config2"), new URL("http://some.other/domain"))); when(corePlugin.getApplicationName()).thenReturn("myapplication"); initializer.onConfigurationInitialized(new StagemonitorConfigurationSourceInitializer.ConfigInitializedArguments(configuration)); // Expecting 3 config source verify(configuration, times(3)).addConfigurationSourceAfter(any(RemotePropertiesConfigurationSource.class), eq(SimpleSource.class)); } }
/** * Should only be used outside of this class by the internal unit tests */ @Deprecated public static void reset(MeasurementSession measurementSession) { started = false; disabled = false; if (configuration == null) { reloadPluginsAndConfiguration(); } if (measurementSession == null) { CorePlugin corePlugin = getPlugin(CorePlugin.class); measurementSession = new MeasurementSession(corePlugin.getApplicationName(), corePlugin.getHostName(), corePlugin.getInstanceName()); } onShutdownActions.add(AgentAttacher.performRuntimeAttachment()); startMonitoring(measurementSession); healthCheckRegistry.register("Startup", new HealthCheck() { @Override protected Result check() throws Exception { if (started) { return Result.healthy(); } else { return Result.unhealthy("stagemonitor is not started"); } } }); logStatus(); new ConfigurationLogger().logConfiguration(configuration); }
when(corePlugin.isStagemonitorActive()).thenReturn(true); when(corePlugin.getThreadPoolQueueCapacityLimit()).thenReturn(1000); when(corePlugin.getApplicationName()).thenReturn("JaxRsRequestNameDeterminerTransformerTest"); when(corePlugin.getInstanceName()).thenReturn("test"); when(tracingPlugin.getDefaultRateLimitSpansPerMinute()).thenReturn(1000000d);
}).when(tracingPlugin).addSpanEventListenerFactory(any()); doReturn(spanWrappingTracer).when(tracingPlugin).getTracer(); doReturn("testApplication").when(corePlugin).getApplicationName(); doReturn("testInstance").when(corePlugin).getInstanceName(); servletPlugin.initializePlugin(new StagemonitorPlugin.InitArguments(mock(Metric2Registry.class), configuration,
private String getApplicationName(FilterConfig filterConfig) { String name = corePlugin.getApplicationName(); if (StringUtils.isEmpty(name)) { name = filterConfig.getServletContext().getServletContextName(); } if (StringUtils.isEmpty(name)) { name = CorePlugin.DEFAULT_APPLICATION_NAME; } return name; }
private synchronized void createMeasurementSession() { if (Stagemonitor.getMeasurementSession().isNull()) { MeasurementSession session = new MeasurementSession(corePlugin.getApplicationName(), corePlugin.getHostName(), corePlugin.getInstanceName()); Stagemonitor.setMeasurementSession(session); } }