Adds Zipkin v2 support (#720)
This adds the ability to use zipkin v2 endpoints natively. It also allows wiring of standard zipkin reporters and senders.
This commit is contained in:
committed by
Marcin Grzejszczak
parent
08a526c61b
commit
4ddf929294
@@ -23,7 +23,7 @@
|
||||
<module>spring-cloud-sleuth-sample-websocket</module>
|
||||
<module>spring-cloud-sleuth-sample-feign</module>
|
||||
<module>spring-cloud-sleuth-sample-ribbon</module>
|
||||
<module>spring-cloud-sleuth-sample-zipkin</module>
|
||||
<module>spring-cloud-sleuth-sample-zipkin2</module>
|
||||
<module>spring-cloud-sleuth-sample-stream</module>
|
||||
<module>spring-cloud-sleuth-sample-zipkin-stream</module>
|
||||
</modules>
|
||||
@@ -59,12 +59,17 @@
|
||||
<dependency>
|
||||
<groupId>io.zipkin.java</groupId>
|
||||
<artifactId>zipkin</artifactId>
|
||||
<version>1.28.0</version>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.zipkin.zipkin2</groupId>
|
||||
<artifactId>zipkin</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.zipkin.java</groupId>
|
||||
<artifactId>zipkin-server</artifactId>
|
||||
<version>1.28.0</version>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-sleuth-sample-zipkin</artifactId>
|
||||
<artifactId>spring-cloud-sleuth-sample-zipkin2</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>spring-cloud-sleuth-sample-zipkin</name>
|
||||
<description>Spring Cloud Sleuth Sample</description>
|
||||
<name>spring-cloud-sleuth-sample-zipkin2</name>
|
||||
<description>Spring Cloud Sleuth Sample Zipkin v2</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
@@ -77,7 +77,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -111,7 +111,7 @@
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<version>3.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -21,11 +21,12 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import zipkin2.Span;
|
||||
import zipkin2.reporter.Reporter;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -49,13 +50,8 @@ public class SampleZipkinApplication {
|
||||
// Use this for debugging (or if there is no Zipkin server running on port 9411)
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "sample.zipkin.enabled", havingValue = "false")
|
||||
public ZipkinSpanReporter spanCollector() {
|
||||
return new ZipkinSpanReporter() {
|
||||
@Override
|
||||
public void report(zipkin.Span span) {
|
||||
log.info(String.format("Reporting span [%s]", span));
|
||||
}
|
||||
};
|
||||
public Reporter<Span> spanReporter() {
|
||||
return Reporter.CONSOLE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinProperties;
|
||||
import org.springframework.cloud.sleuth.zipkin2.ZipkinProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
Reference in New Issue
Block a user