Zipkin sender type is case insensitive; fixes gh-843

This commit is contained in:
Marcin Grzejszczak
2018-01-31 15:34:40 +01:00
parent 68f107c2b6
commit 89e579201b
2 changed files with 21 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ class ZipkinSenderCondition extends SpringBootCondition {
String senderType = getType(((AnnotationMetadata) md).getClassName());
String value = resolver.getProperty("type");
if (value.equals(senderType)) {
if (value.equalsIgnoreCase(senderType)) {
return ConditionOutcome.match(message.because(value + " sender type"));
}
return ConditionOutcome.noMatch(message.because(value + " sender type"));

View File

@@ -26,7 +26,6 @@ import org.junit.rules.ExpectedException;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.SpanReporter;
@@ -154,6 +153,26 @@ public class ZipkinAutoConfigurationTests {
context.close();
}
@Test
public void canOverrideBySenderAndIsCaseInsensitive() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "spring.zipkin.sender.type:WEB");
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
RabbitAutoConfiguration.class,
KafkaAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
assertThat(spanReporter).extracting("reporter.sender").allSatisfy(
s -> assertThat(s.getClass().getSimpleName()).isEqualTo("RestTemplateSender")
);
context.close();
}
@Test
public void rabbitWinsWhenKafkaPresent() throws Exception {
context = new AnnotationConfigApplicationContext();