use of org.stagemonitor.configuration.ConfigurationRegistry in project apm-agent-java by elastic.
the class ApmServerReporterIntegrationTest method setUp.
@BeforeEach
void setUp() {
handler = exchange -> {
receivedHttpRequests.incrementAndGet();
exchange.setStatusCode(200).endExchange();
};
receivedHttpRequests.set(0);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new AfterburnerModule());
final ConfigurationRegistry config = SpyConfiguration.createSpyConfig();
reporterConfiguration = config.getConfig(ReporterConfiguration.class);
when(reporterConfiguration.getFlushInterval()).thenReturn(-1);
when(reporterConfiguration.getServerUrl()).thenReturn("http://localhost:" + port);
payloadSender = new ApmServerHttpPayloadSender(new OkHttpClient(), new JacksonPayloadSerializer(objectMapper), reporterConfiguration);
SystemInfo system = new SystemInfo("x64", "localhost", "platform");
reporter = new ApmServerReporter(config, new Service(), new ProcessInfo("title"), system, payloadSender, false, reporterConfiguration);
}
use of org.stagemonitor.configuration.ConfigurationRegistry in project apm-agent-java by elastic.
the class ApmServerReporterTest method setUp.
@BeforeEach
void setUp() {
final ConfigurationRegistry configurationRegistry = SpyConfiguration.createSpyConfig();
ReporterConfiguration reporterConfiguration = configurationRegistry.getConfig(ReporterConfiguration.class);
when(reporterConfiguration.getFlushInterval()).thenReturn(-1);
when(reporterConfiguration.getMaxQueueSize()).thenReturn(0);
SystemInfo system = new SystemInfo("x64", "localhost", "platform");
reporter = new ApmServerReporter(configurationRegistry, new Service(), new ProcessInfo("title"), system, mock(PayloadSender.class), true, reporterConfiguration);
}
use of org.stagemonitor.configuration.ConfigurationRegistry in project apm-agent-java by elastic.
the class BodyProcessorTest method setUp.
@BeforeEach
void setUp() {
bodyProcessor = new BodyProcessor();
ConfigurationRegistry configurationRegistry = SpyConfiguration.createSpyConfig();
bodyProcessor.init(configurationRegistry);
config = configurationRegistry.getConfig(WebConfiguration.class);
}
use of org.stagemonitor.configuration.ConfigurationRegistry in project apm-agent-java by elastic.
the class ElasticApmTracerBuilder method getDefaultConfigurationRegistry.
private ConfigurationRegistry getDefaultConfigurationRegistry() {
try {
final ConfigurationRegistry configurationRegistry = ConfigurationRegistry.builder().addConfigSource(new PrefixingConfigurationSourceWrapper(new SystemPropertyConfigurationSource(), "elastic.apm.")).addConfigSource(new PrefixingConfigurationSourceWrapper(new EnvironmentVariableConfigurationSource(), "ELASTIC_APM_")).addConfigSource(new PropertyFileConfigurationSource("elasticapm.properties")).optionProviders(ServiceLoader.load(ConfigurationOptionProvider.class, ElasticApmTracer.class.getClassLoader())).failOnMissingRequiredValues(true).build();
configurationRegistry.scheduleReloadAtRate(30, TimeUnit.SECONDS);
return configurationRegistry;
} catch (IllegalStateException e) {
logger.warn(e.getMessage());
return ConfigurationRegistry.builder().addConfigSource(new SimpleSource("Noop Configuration").add(CoreConfiguration.ACTIVE, "false").add(CoreConfiguration.INSTRUMENT, "false").add(CoreConfiguration.SERVICE_NAME, "none").add(CoreConfiguration.SAMPLE_RATE, "0")).optionProviders(ServiceLoader.load(ConfigurationOptionProvider.class, ElasticApmTracer.class.getClassLoader())).build();
}
}
Aggregations