Search in sources :

Example 1 with PrefixingConfigurationSourceWrapper

use of co.elastic.apm.configuration.PrefixingConfigurationSourceWrapper 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

PrefixingConfigurationSourceWrapper (co.elastic.apm.configuration.PrefixingConfigurationSourceWrapper)1 ConfigurationOptionProvider (org.stagemonitor.configuration.ConfigurationOptionProvider)1 ConfigurationRegistry (org.stagemonitor.configuration.ConfigurationRegistry)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