Commit b8f11e79 by Spencer Gibb

Atlas no longer requires a RestTemplate bean.

fixes gh-881
parent 4f31596e
...@@ -17,6 +17,7 @@ import java.util.Collection; ...@@ -17,6 +17,7 @@ import java.util.Collection;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.metrics.export.Exporter; import org.springframework.boot.actuate.metrics.export.Exporter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
...@@ -42,6 +43,10 @@ public class AtlasConfiguration { ...@@ -42,6 +43,10 @@ public class AtlasConfiguration {
@Autowired(required = false) @Autowired(required = false)
private Collection<AtlasTagProvider> tagProviders; private Collection<AtlasTagProvider> tagProviders;
@Autowired(required = false)
@Qualifier("atlasRestTemplate")
private RestTemplate restTemplate = new RestTemplate();
@Bean @Bean
public AtlasMetricObserverConfigBean atlasObserverConfig() { public AtlasMetricObserverConfigBean atlasObserverConfig() {
return new AtlasMetricObserverConfigBean(); return new AtlasMetricObserverConfigBean();
...@@ -49,7 +54,7 @@ public class AtlasConfiguration { ...@@ -49,7 +54,7 @@ public class AtlasConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public AtlasMetricObserver atlasObserver(AtlasMetricObserverConfigBean atlasObserverConfig, RestTemplate restTemplate) { public AtlasMetricObserver atlasObserver(AtlasMetricObserverConfigBean atlasObserverConfig) {
BasicTagList tags = (BasicTagList) BasicTagList.EMPTY; BasicTagList tags = (BasicTagList) BasicTagList.EMPTY;
if (tagProviders != null) { if (tagProviders != null) {
for (AtlasTagProvider tagProvider : tagProviders) { for (AtlasTagProvider tagProvider : tagProviders) {
......
...@@ -18,9 +18,9 @@ import java.util.Properties; ...@@ -18,9 +18,9 @@ import java.util.Properties;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
...@@ -41,10 +41,10 @@ import com.netflix.servo.monitor.DynamicCounter; ...@@ -41,10 +41,10 @@ import com.netflix.servo.monitor.DynamicCounter;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
public class AtlasExporterTests { public class AtlasExporterTests {
@Autowired @Autowired
RestTemplate restTemplate; private RestTemplate restTemplate;
@Autowired @Autowired
AtlasExporter atlasExporter; private AtlasExporter atlasExporter;
@Test @Test
public void exportMetricsAtPeriodicIntervals() { public void exportMetricsAtPeriodicIntervals() {
...@@ -68,7 +68,7 @@ public class AtlasExporterTests { ...@@ -68,7 +68,7 @@ public class AtlasExporterTests {
@EnableAtlas @EnableAtlas
class AtlasExporterConfiguration { class AtlasExporterConfiguration {
@LoadBalanced @Qualifier("atlasRestTemplate")
@Bean @Bean
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment