diff --git a/spring-cloud-sleuth-zipkin/pom.xml b/spring-cloud-sleuth-zipkin/pom.xml
index 580d30f49..63f3e2892 100644
--- a/spring-cloud-sleuth-zipkin/pom.xml
+++ b/spring-cloud-sleuth-zipkin/pom.xml
@@ -1,4 +1,20 @@
+
+
@@ -60,6 +76,16 @@
zipkin-junit
test
+
+ org.aspectj
+ aspectjrt
+ test
+
+
+ org.aspectj
+ aspectjweaver
+ test
+
diff --git a/spring-cloud-sleuth-zipkin/src/main/java/org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.java b/spring-cloud-sleuth-zipkin/src/main/java/org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.java
index 415aa93ca..19773a5d3 100644
--- a/spring-cloud-sleuth-zipkin/src/main/java/org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.java
+++ b/spring-cloud-sleuth-zipkin/src/main/java/org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2015 the original author or authors.
+ * Copyright 2013-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.sleuth.Sampler;
+import org.springframework.cloud.sleuth.SpanReporter;
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.cloud.sleuth.metric.SpanMetricReporter;
import org.springframework.cloud.sleuth.sampler.PercentageBasedSampler;
@@ -64,7 +65,7 @@ public class ZipkinAutoConfiguration {
}
@Bean
- public ZipkinSpanListener sleuthTracer(ZipkinSpanReporter reporter, EndpointLocator endpointLocator) {
+ public SpanReporter zipkinSpanListener(ZipkinSpanReporter reporter, EndpointLocator endpointLocator) {
return new ZipkinSpanListener(reporter, endpointLocator);
}
diff --git a/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java b/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java
index 584ec3db3..2e16e0e09 100644
--- a/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java
+++ b/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 the original author or authors.
+ * Copyright 2013-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,21 +24,17 @@ import javax.annotation.PostConstruct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.sleuth.Sampler;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.SpanReporter;
import org.springframework.cloud.sleuth.Tracer;
-import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
-import org.springframework.cloud.sleuth.log.NoOpSpanLogger;
-import org.springframework.cloud.sleuth.log.SpanLogger;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanListenerTests.TestConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import zipkin.Constants;
@@ -56,13 +52,12 @@ public class ZipkinSpanListenerTests {
@Autowired Tracer tracer;
@Autowired ApplicationContext application;
- @Autowired ZipkinTestConfiguration test;
- @Autowired ZipkinSpanListener listener;
- @Autowired SpanReporter spanReporter;
+ @Autowired TestConfiguration test;
+ @Autowired ZipkinSpanListener spanReporter;
@PostConstruct
public void init() {
- this.test.spans.clear();
+ this.test.zipkinSpans.clear();
}
Span parent = Span.builder().traceId(1L).name("http:parent").remote(true).build();
@@ -74,7 +69,7 @@ public class ZipkinSpanListenerTests {
this.parent.logEvent("hystrix/retry"); // System.currentTimeMillis
this.parent.stop();
- zipkin.Span result = this.listener.convert(this.parent);
+ zipkin.Span result = this.spanReporter.convert(this.parent);
assertThat(result.timestamp)
.isEqualTo(this.parent.getBegin() * 1000);
@@ -91,10 +86,10 @@ public class ZipkinSpanListenerTests {
this.parent.logEvent("hystrix/retry");
this.parent.tag("spring-boot/version", "1.3.1.RELEASE");
- zipkin.Span result = this.listener.convert(this.parent);
+ zipkin.Span result = this.spanReporter.convert(this.parent);
assertThat(result.annotations.get(0).endpoint)
- .isEqualTo(this.listener.endpointLocator.local());
+ .isEqualTo(this.spanReporter.endpointLocator.local());
assertThat(result.binaryAnnotations.get(0).endpoint)
.isEqualTo(result.annotations.get(0).endpoint);
}
@@ -102,7 +97,7 @@ public class ZipkinSpanListenerTests {
/** zipkin's Endpoint.serviceName should never be null. */
@Test
public void localEndpointIncludesServiceName() {
- assertThat(this.listener.endpointLocator.local().serviceName)
+ assertThat(this.spanReporter.endpointLocator.local().serviceName)
.isNotEmpty();
}
@@ -115,9 +110,9 @@ public class ZipkinSpanListenerTests {
public void spanWithoutAnnotationsLogsComponent() {
Span context = this.tracer.createSpan("http:foo");
this.tracer.close(context);
- assertEquals(1, this.test.spans.size());
- assertThat(this.test.spans.get(0).binaryAnnotations.get(0).endpoint.serviceName)
- .isEqualTo("unknown"); // TODO: "unknown" bc process id, documented as not nullable, is null.
+ assertEquals(1, this.test.zipkinSpans.size());
+ assertThat(this.test.zipkinSpans.get(0).binaryAnnotations.get(0).value)
+ .isEqualTo("unknown".getBytes()); // TODO: "unknown" bc process id, documented as not nullable, is null.
}
@Test
@@ -127,7 +122,7 @@ public class ZipkinSpanListenerTests {
logServerReceived(this.parent);
logServerSent(this.spanReporter, this.parent);
this.tracer.close(context);
- assertEquals(2, this.test.spans.size());
+ assertEquals(2, this.test.zipkinSpans.size());
}
void logServerReceived(Span parent) {
@@ -148,7 +143,7 @@ public class ZipkinSpanListenerTests {
this.parent.logEvent("hystrix/retry");
this.parent.stop();
- zipkin.Span result = this.listener.convert(this.parent);
+ zipkin.Span result = this.spanReporter.convert(this.parent);
assertThat(result.binaryAnnotations)
.extracting(input -> input.key)
@@ -160,12 +155,11 @@ public class ZipkinSpanListenerTests {
this.parent.logEvent(Constants.CLIENT_SEND);
this.parent.stop();
- zipkin.Span result = this.listener.convert(this.parent);
+ zipkin.Span result = this.spanReporter.convert(this.parent);
assertThat(result.binaryAnnotations)
.filteredOn("key", Constants.SERVER_ADDR)
- .extracting(input -> input.endpoint.serviceName)
- .containsOnly("unknown");
+ .isNotEmpty();
}
@Test
@@ -174,7 +168,7 @@ public class ZipkinSpanListenerTests {
this.parent.tag(Span.SPAN_PEER_SERVICE_TAG_NAME, "fooservice");
this.parent.stop();
- zipkin.Span result = this.listener.convert(this.parent);
+ zipkin.Span result = this.spanReporter.convert(this.parent);
assertThat(result.binaryAnnotations)
.filteredOn("key", Constants.SERVER_ADDR)
@@ -183,30 +177,21 @@ public class ZipkinSpanListenerTests {
}
@Configuration
- @Import({ ZipkinTestConfiguration.class, ZipkinAutoConfiguration.class, TraceAutoConfiguration.class,
- PropertyPlaceholderAutoConfiguration.class })
+ @EnableAutoConfiguration
protected static class TestConfiguration {
- @Bean
- SpanLogger spanLogger() {
- return new NoOpSpanLogger();
- }
- }
-
- @Configuration
- protected static class ZipkinTestConfiguration {
-
- private List spans = new ArrayList<>();
+ private List zipkinSpans = new ArrayList<>();
@Bean
- public Sampler defaultSampler() {
+ public Sampler sampler() {
return new AlwaysSampler();
}
@Bean
public ZipkinSpanReporter reporter() {
- return this.spans::add;
+ return this.zipkinSpans::add;
}
}
+
}