public Reporter createReporter(ConfigurationRegistry configurationRegistry, @Nullable String frameworkName, @Nullable String frameworkVersion) { final ReporterConfiguration reporterConfiguration = configurationRegistry.getConfig(ReporterConfiguration.class); ExecutorService healthCheckExecutorService = Executors.newFixedThreadPool(1, new ThreadFactory() { @Override public Thread newThread(Runnable r) { final Thread thread = new Thread(r); thread.setName("apm-server-healthcheck"); thread.setDaemon(true); return thread; } }); healthCheckExecutorService.submit(new ApmServerHealthChecker(reporterConfiguration)); healthCheckExecutorService.shutdown(); final ReportingEventHandler reportingEventHandler = getReportingEventHandler(configurationRegistry, frameworkName, frameworkVersion, reporterConfiguration); return new ApmServerReporter(true, reporterConfiguration, reportingEventHandler); }
@BeforeEach void setUp() { final ConfigurationRegistry configurationRegistry = SpyConfiguration.createSpyConfig(); ReporterConfiguration reporterConfiguration = configurationRegistry.getConfig(ReporterConfiguration.class); when(reporterConfiguration.getFlushInterval()).thenReturn(TimeDuration.of("-1ms")); when(reporterConfiguration.getMaxQueueSize()).thenReturn(0); reportingEventHandler = mock(ReportingEventHandler.class); reporter = new ApmServerReporter(true, reporterConfiguration, reportingEventHandler); }
@BeforeEach void setUp() throws Exception { handler = exchange -> { if (!exchange.getRequestPath().equals("/healthcheck")) { receivedHttpRequests.incrementAndGet(); } exchange.setStatusCode(200).endExchange(); }; receivedHttpRequests.set(0); config = SpyConfiguration.createSpyConfig(); reporterConfiguration = config.getConfig(ReporterConfiguration.class); when(reporterConfiguration.getFlushInterval()).thenReturn(TimeDuration.of("-1s")); when(reporterConfiguration.getServerUrls()).thenReturn(Collections.singletonList(new URL("http://localhost:" + port))); SystemInfo system = new SystemInfo("x64", "localhost", "platform"); final Service service = new Service(); final ProcessInfo title = new ProcessInfo("title"); final ProcessorEventHandler processorEventHandler = ProcessorEventHandler.loadProcessors(config); final IntakeV2ReportingEventHandler v2handler = new IntakeV2ReportingEventHandler(service, title, system, reporterConfiguration, processorEventHandler, new DslJsonSerializer(mock(StacktraceConfiguration.class))); reporter = new ApmServerReporter(false, reporterConfiguration, v2handler); }