Search in sources :

Example 1 with ConfigurationRegistry

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);
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) OkHttpClient(okhttp3.OkHttpClient) SystemInfo(co.elastic.apm.impl.payload.SystemInfo) JacksonPayloadSerializer(co.elastic.apm.report.serialize.JacksonPayloadSerializer) ConfigurationRegistry(org.stagemonitor.configuration.ConfigurationRegistry) Service(co.elastic.apm.impl.payload.Service) ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ConfigurationRegistry

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);
}
Also used : SystemInfo(co.elastic.apm.impl.payload.SystemInfo) ConfigurationRegistry(org.stagemonitor.configuration.ConfigurationRegistry) Service(co.elastic.apm.impl.payload.Service) ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ConfigurationRegistry

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);
}
Also used : ConfigurationRegistry(org.stagemonitor.configuration.ConfigurationRegistry) WebConfiguration(co.elastic.apm.configuration.WebConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ConfigurationRegistry

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();
    }
}
Also used : ConfigurationOptionProvider(org.stagemonitor.configuration.ConfigurationOptionProvider) PrefixingConfigurationSourceWrapper(co.elastic.apm.configuration.PrefixingConfigurationSourceWrapper) SystemPropertyConfigurationSource(org.stagemonitor.configuration.source.SystemPropertyConfigurationSource) SimpleSource(org.stagemonitor.configuration.source.SimpleSource) ConfigurationRegistry(org.stagemonitor.configuration.ConfigurationRegistry) PropertyFileConfigurationSource(org.stagemonitor.configuration.source.PropertyFileConfigurationSource) EnvironmentVariableConfigurationSource(org.stagemonitor.configuration.source.EnvironmentVariableConfigurationSource)

Aggregations

ConfigurationRegistry (org.stagemonitor.configuration.ConfigurationRegistry)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ProcessInfo (co.elastic.apm.impl.payload.ProcessInfo)2 Service (co.elastic.apm.impl.payload.Service)2 SystemInfo (co.elastic.apm.impl.payload.SystemInfo)2 PrefixingConfigurationSourceWrapper (co.elastic.apm.configuration.PrefixingConfigurationSourceWrapper)1 WebConfiguration (co.elastic.apm.configuration.WebConfiguration)1 JacksonPayloadSerializer (co.elastic.apm.report.serialize.JacksonPayloadSerializer)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)1 OkHttpClient (okhttp3.OkHttpClient)1 ConfigurationOptionProvider (org.stagemonitor.configuration.ConfigurationOptionProvider)1 EnvironmentVariableConfigurationSource (org.stagemonitor.configuration.source.EnvironmentVariableConfigurationSource)1 PropertyFileConfigurationSource (org.stagemonitor.configuration.source.PropertyFileConfigurationSource)1 SimpleSource (org.stagemonitor.configuration.source.SimpleSource)1 SystemPropertyConfigurationSource (org.stagemonitor.configuration.source.SystemPropertyConfigurationSource)1