From ab50acf11a11aef7cf8f170fab7f2ec04ca5d3d8 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Wed, 22 Nov 2017 14:27:33 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- multi/multi__customizations.html | 15 ++++++++++++++- single/spring-cloud-sleuth.html | 15 ++++++++++++++- spring-cloud-sleuth.xml | 15 ++++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/multi/multi__customizations.html b/multi/multi__customizations.html index 41e61c5ba..bf015a354 100644 --- a/multi/multi__customizations.html +++ b/multi/multi__customizations.html @@ -119,7 +119,20 @@ TraceFilter myTraceFilter(BeanFactory beanFactory,

9.5 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.

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]Important

Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

9.6 Custom service name

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]Important

Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

9.6 Custom service name

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/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,

9.5 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.

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]Important

Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

9.6 Custom service name

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]Important

Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

9.6 Custom service name

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) { 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] +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); +} Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.