diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml
index 36dead8a4..37b90d0df 100644
--- a/benchmarks/pom.xml
+++ b/benchmarks/pom.xml
@@ -103,7 +103,7 @@
org.assertj
assertj-core
- 2.1.0
+ 3.5.2
compile
diff --git a/docs/src/main/asciidoc/spring-cloud-sleuth.adoc b/docs/src/main/asciidoc/spring-cloud-sleuth.adoc
index 330c4dfc5..f0ccc7bbe 100644
--- a/docs/src/main/asciidoc/spring-cloud-sleuth.adoc
+++ b/docs/src/main/asciidoc/spring-cloud-sleuth.adoc
@@ -272,6 +272,19 @@ And you could register them like this:
include::../../../..//spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterCustomExtractorTests.java[tags=configuration,indent=0]
----
+=== Custom SA tag in Zipkin
+
+Sometimes you want to create a manual Span that will wrap a call to an external service which is not instrumented.
+What you can do is to create a span with the `peer.service` tag that will contain a value of the service that you want to call.
+Below you can see an example of a call to Redis that is wrapped in such a span.
+
+[source,java]
+----
+include::../../../..//spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java[tags=service_name,indent=0]
+----
+
+IMPORTANT: Remember not to add both `peer.service` tag and the `SA` tag! You have to add only `peer.service`.
+
== Span Data as Messages
You can accumulate and send span data over
diff --git a/pom.xml b/pom.xml
index 09fe00956..7e0194875 100644
--- a/pom.xml
+++ b/pom.xml
@@ -195,7 +195,7 @@
org.assertj
assertj-core
- 3.5.1
+ 3.5.2
test
diff --git a/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java b/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java
index 02ace6de6..c30ce440e 100644
--- a/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java
+++ b/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java
@@ -1,16 +1,27 @@
package org.springframework.cloud.sleuth.zipkin;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.junit.Rule;
import org.junit.Test;
+import org.springframework.boot.autoconfigure.web.ServerProperties;
+import org.springframework.cloud.sleuth.DefaultSpanNamer;
+import org.springframework.cloud.sleuth.Tracer;
+import org.springframework.cloud.sleuth.log.NoOpSpanLogger;
import org.springframework.cloud.sleuth.metric.CounterServiceBasedSpanMetricReporter;
import org.springframework.cloud.sleuth.metric.SpanMetricReporter;
-import zipkin.Span;
+import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
+import org.springframework.cloud.sleuth.trace.DefaultTracer;
+import org.springframework.cloud.sleuth.util.ExceptionUtils;
+import zipkin.Span;
import zipkin.junit.HttpFailure;
import zipkin.junit.ZipkinRule;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.BDDAssertions.then;
public class HttpZipkinSpanReporterTest {
@@ -113,6 +124,36 @@ public class HttpZipkinSpanReporterTest {
assertThat(this.inMemorySpanCounter.getDroppedSpans()).isEqualTo(2);
}
+ @Test
+ public void should_change_the_service_name_in_zipkin_to_the_manually_provided_one() {
+ AtomicReference receivedSpan = new AtomicReference<>();
+ Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(), new DefaultSpanNamer(),
+ new NoOpSpanLogger(), new ZipkinSpanListener(receivedSpan::set,
+ new ServerPropertiesEndpointLocator(new ServerProperties(), "foo")));
+ // tag::service_name[]
+ org.springframework.cloud.sleuth.Span newSpan = tracer.createSpan("redis");
+ try {
+ newSpan.tag("redis.op", "get");
+ newSpan.tag("lc", "redis");
+ newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_SEND);
+ // call redis service e.g
+ // return (SomeObj) redisTemplate.opsForHash().get("MYHASH", someObjKey);
+ } finally {
+ newSpan.tag("peer.service", "redisService");
+ newSpan.tag("peer.ipv4", "1.2.3.4");
+ newSpan.tag("peer.port", "1234");
+ newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_RECV);
+ tracer.close(newSpan);
+ }
+ // end::service_name[]
+
+ then(tracer.getCurrentSpan()).isNull();
+ then(ExceptionUtils.getLastException()).isNull();
+ then(receivedSpan.get().binaryAnnotations)
+ .flatExtracting(input -> input.key, input -> new String(input.value))
+ .contains("peer.service", "redisService");
+ }
+
static Span span(long traceId, String spanName) {
return Span.builder().traceId(traceId).id(traceId).name(spanName).build();
}