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.
Unresolved directive in spring-cloud-sleuth.adoc - 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 |
By default Sleuth assumes that when you send a span to Zipkin, you want the span’s service name +Below you can see an example of a call to Redis that is wrapped in such a span.
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); +}
![]() | Important |
|---|---|
Remember not to add both |
By default Sleuth assumes that when you send a span to Zipkin, you want the span’s service name
to be equal to 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 Remember not to add both spring.application.name value. That’s not always the case though. There
are situations in which you want to explicitly provide a different service name for all spans coming
from your application. To achieve that it’s enough to just pass the following property
diff --git a/single/spring-cloud-sleuth.html b/single/spring-cloud-sleuth.html
index 4ade3e8ca..9ef20fe2e 100644
--- a/single/spring-cloud-sleuth.html
+++ b/single/spring-cloud-sleuth.html
@@ -536,7 +536,20 @@ TraceFilter myTraceFilter(BeanFactory beanFactory, 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.Unresolved directive in spring-cloud-sleuth.adoc - include::../../../..//spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java[tags=service_name,indent=0]![[Important]](images/important.png)
Important peer.service tag and the SA tag! You have to add only peer.service.
By default Sleuth assumes that when you send a span to Zipkin, you want the span’s service name +Below you can see an example of a call to Redis that is wrapped in such a span.
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); +}
![]() | Important |
|---|---|
Remember not to add both |
By default Sleuth assumes that when you send a span to Zipkin, you want the span’s service name
to be equal to spring.application.name value. That’s not always the case though. There
are situations in which you want to explicitly provide a different service name for all spans coming
from your application. To achieve that it’s enough to just pass the following property
diff --git a/spring-cloud-sleuth.xml b/spring-cloud-sleuth.xml
index 02bf97fb7..abbcfa76e 100644
--- a/spring-cloud-sleuth.xml
+++ b/spring-cloud-sleuth.xml
@@ -1233,7 +1233,20 @@ TraceFilter myTraceFilter(BeanFactory beanFactory, final Tracer tracer) {