From 265362b0f3bccbb48a1ca34228356c57ff0d3d79 Mon Sep 17 00:00:00 2001
From: buildmaster myService):
spring.zipkin.service.name: myServiceBefore reporting spans (for example, to Zipkin) you may want to modify that span in some way.
-You can do so by using the SpanAdjuster interface.
In Sleuth, we generate spans with a fixed name.
+You can do so by using the FinishedSpanHandler interface.
In Sleuth, we generate spans with a fixed name.
Some users want to modify the name depending on values of tags.
-You can implement the SpanAdjuster interface to alter that name.
The following example shows how to register two beans that implement SpanAdjuster:
@Bean SpanAdjuster adjusterOne() { - return span -> span.toBuilder().name("foo").build(); +You can implement theFinishedSpanHandlerinterface to alter that name.The following example shows how to register two beans that implement
FinishedSpanHandler:@Bean FinishedSpanHandler handlerOne() { + return new FinishedSpanHandler() { + @Override public boolean handle(TraceContext traceContext, MutableSpan span) { + span.name("foo"); + return true; // keep this span + } + }; } -@Bean SpanAdjuster adjusterTwo() { - return span -> span.toBuilder().name(span.name() + " bar").build(); +@Bean FinishedSpanHandler handlerTwo() { + return new FinishedSpanHandler() { + @Override public boolean handle(TraceContext traceContext, MutableSpan span) { + span.name(span.name() + " bar"); + return true; // keep this span + } + }; }The preceding example results in changing the name of the reported span to
foo bar, just before it gets reported (for example, to Zipkin).
![]() | Important |
|---|---|
This section is about defining host from service discovery. It is NOT about finding Zipkin through service discovery. |
To define the host that corresponds to a particular span, we need to resolve the host name and port.
The default approach is to take these values from server properties.
diff --git a/single/spring-cloud-sleuth.html b/single/spring-cloud-sleuth.html
index 5a225a8d6..be9331267 100644
--- a/single/spring-cloud-sleuth.html
+++ b/single/spring-cloud-sleuth.html
@@ -723,14 +723,24 @@ You can customize the tags or modify the response headers by registering your ow
That is 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, you can pass the following property to your application to override that value (the example is for a service named myService):
spring.zipkin.service.name: myServiceBefore reporting spans (for example, to Zipkin) you may want to modify that span in some way.
-You can do so by using the SpanAdjuster interface.
In Sleuth, we generate spans with a fixed name.
+You can do so by using the FinishedSpanHandler interface.
In Sleuth, we generate spans with a fixed name.
Some users want to modify the name depending on values of tags.
-You can implement the SpanAdjuster interface to alter that name.
The following example shows how to register two beans that implement SpanAdjuster:
@Bean SpanAdjuster adjusterOne() { - return span -> span.toBuilder().name("foo").build(); +You can implement theFinishedSpanHandlerinterface to alter that name.The following example shows how to register two beans that implement
FinishedSpanHandler:@Bean FinishedSpanHandler handlerOne() { + return new FinishedSpanHandler() { + @Override public boolean handle(TraceContext traceContext, MutableSpan span) { + span.name("foo"); + return true; // keep this span + } + }; } -@Bean SpanAdjuster adjusterTwo() { - return span -> span.toBuilder().name(span.name() + " bar").build(); +@Bean FinishedSpanHandler handlerTwo() { + return new FinishedSpanHandler() { + @Override public boolean handle(TraceContext traceContext, MutableSpan span) { + span.name(span.name() + " bar"); + return true; // keep this span + } + }; }The preceding example results in changing the name of the reported span to
foo bar, just before it gets reported (for example, to Zipkin).
![]() | Important |
|---|---|
This section is about defining host from service discovery. It is NOT about finding Zipkin through service discovery. |
To define the host that corresponds to a particular span, we need to resolve the host name and port.
The default approach is to take these values from server properties.
diff --git a/spring-cloud-sleuth.xml b/spring-cloud-sleuth.xml
index 784929da3..e5cfffd74 100644
--- a/spring-cloud-sleuth.xml
+++ b/spring-cloud-sleuth.xml
@@ -1547,17 +1547,27 @@ To achieve that, you can pass the following property to your application to over