Reputation: 937
In my Spring Boot application I use spring-cloud-starter-sleuth (Version Hoxton.SR10) for tracing. It is (still) a monolithic application so I widely use the @NewSpan
annotation for creating new spans.
In my development environment I also use spring-cloud-starter-zipkin, which works great.
But on the servers of our customers I don't have access to any Zipkin server nor am allowed to install one. Is there any possibility to save the data Spring is sending to Zipkin and import that to my local Zipkin server?
Solution thanks to Marcin's inspiration:
@Configuration
@ConditionalOnProperty(name = "custom.property", havingValue = "true")
public class SleuthConfiguration {
@Bean("zipkinSender")
Sender restTemplateSender() {
return new Sender() {
public Encoding encoding() { return Encoding.JSON; }
public int messageMaxBytes() { return Integer.MAX_VALUE; }
public int messageSizeInBytes(List<byte[]> list) { return Integer.MAX_VALUE; }
@Override
public Call<Void> sendSpans(List<byte[]> list) {
String result = convertByteArrayToList(list);
saveToFile(result);
return new Call.Base<Void>() {...};
}
};
}
}
Implement convertByteArrayToList
and saveToFile
your own, because my solution depends on custom libraries.
Upvotes: 0
Views: 363
Reputation: 11179
You could create your own SpanHandler
bean that takes the FinishedSpan
, converts into JSON and stores it somewhere on your drive. Then you could just iterate over jsons and upload them to the Zipkin server
Upvotes: 2