Span Adjuster (#567)

with this change, we're adding a possibility to fully customize the span before it gets reported to e.g. Zipkin

fixes #553
This commit is contained in:
Marcin Grzejszczak
2017-04-19 10:35:48 +02:00
committed by GitHub
parent a879dc9e30
commit 64791deabd
13 changed files with 255 additions and 28 deletions

View File

@@ -309,6 +309,26 @@ By default Sleuth assumes that when you send a span to Zipkin, you want the span
spring.zipkin.service.name: foo
----
=== Customization of reported spans
Before reporting spans to e.g. Zipkin you can be interested in modifying that span in some way.
You can achieve that by using the `SpanAdjuster` interface.
Example of usage:
In Sleuth we're generating spans with a fixed name. Some users want to modify the name depending on values
of tags. Implementation of the `SpanAdjuster` interface can be used to alter that name. Example:
[source,yaml]
----
@Bean
SpanAdjuster customSpanAdjuster() {
return span -> span.toBuilder().name(scrub(span.getName())).build();
}
----
This will lead in changing the name of the reported span just before it gets sent to Zipkin.
=== Host locator
In order to define the host that is corresponding to a particular span we need to resolve the host name