BAEL-574 adding Zipkin Span Reporters to define the URL from eureka
This commit is contained in:
parent
bebef9a230
commit
c4b693745b
|
@ -0,0 +1,32 @@
|
|||
package com.baeldung.spring.cloud.bootstrap.gateway;
|
||||
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.EurekaClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.sleuth.metric.SpanMetricReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinProperties;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import zipkin.Span;
|
||||
|
||||
@Configuration
|
||||
public class EurekaZipkinSpanReporter implements ZipkinSpanReporter {
|
||||
|
||||
@Autowired
|
||||
private EurekaClient eurekaClient;
|
||||
@Autowired
|
||||
private SpanMetricReporter spanMetricReporter;
|
||||
@Autowired
|
||||
private ZipkinProperties zipkinProperties;
|
||||
@Value("${spring.sleuth.web.skipPattern}")
|
||||
private String skipPattern;
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false);
|
||||
HttpZipkinSpanReporter reporter = new HttpZipkinSpanReporter(instance.getHomePageUrl(), zipkinProperties.getFlushInterval(), zipkinProperties.getCompression().isEnabled(), spanMetricReporter);
|
||||
if (!span.name.matches(skipPattern)) reporter.report(span);
|
||||
}
|
||||
}
|
|
@ -11,5 +11,5 @@ zuul.routes.zipkin.sensitive-headers=Set-Cookie,Authorization
|
|||
hystrix.command.zipkin.execution.isolation.thread.timeoutInMilliseconds=600000
|
||||
|
||||
spring.sleuth.sampler.percentage=1.0
|
||||
spring.sleuth.web.skipPattern=(.+?cleanup.*|.+favicon.*)
|
||||
spring.sleuth.web.skipPattern=(^cleanup.*|.+favicon.*)
|
||||
spring.zipkin.base-url=http://zipkin
|
|
@ -0,0 +1,32 @@
|
|||
package com.baeldung.spring.cloud.bootstrap.svcbook;
|
||||
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.EurekaClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.sleuth.metric.SpanMetricReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinProperties;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import zipkin.Span;
|
||||
|
||||
@Configuration
|
||||
public class EurekaZipkinSpanReporter implements ZipkinSpanReporter {
|
||||
|
||||
@Autowired
|
||||
private EurekaClient eurekaClient;
|
||||
@Autowired
|
||||
private SpanMetricReporter spanMetricReporter;
|
||||
@Autowired
|
||||
private ZipkinProperties zipkinProperties;
|
||||
@Value("${spring.sleuth.web.skipPattern}")
|
||||
private String skipPattern;
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false);
|
||||
HttpZipkinSpanReporter reporter = new HttpZipkinSpanReporter(instance.getHomePageUrl(), zipkinProperties.getFlushInterval(), zipkinProperties.getCompression().isEnabled(), spanMetricReporter);
|
||||
if (!span.name.matches(skipPattern)) reporter.report(span);
|
||||
}
|
||||
}
|
|
@ -7,4 +7,4 @@ spring.cloud.config.password=configPassword
|
|||
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword@localhost:8082/eureka/
|
||||
|
||||
spring.sleuth.sampler.percentage=1.0
|
||||
spring.zipkin.base-url=http://zipkin
|
||||
spring.sleuth.web.skipPattern=(^cleanup.*)
|
|
@ -0,0 +1,32 @@
|
|||
package com.baeldung.spring.cloud.bootstrap.svcrating;
|
||||
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.EurekaClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.sleuth.metric.SpanMetricReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinProperties;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import zipkin.Span;
|
||||
|
||||
@Configuration
|
||||
public class EurekaZipkinSpanReporter implements ZipkinSpanReporter {
|
||||
|
||||
@Autowired
|
||||
private EurekaClient eurekaClient;
|
||||
@Autowired
|
||||
private SpanMetricReporter spanMetricReporter;
|
||||
@Autowired
|
||||
private ZipkinProperties zipkinProperties;
|
||||
@Value("${spring.sleuth.web.skipPattern}")
|
||||
private String skipPattern;
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false);
|
||||
HttpZipkinSpanReporter reporter = new HttpZipkinSpanReporter(instance.getHomePageUrl(), zipkinProperties.getFlushInterval(), zipkinProperties.getCompression().isEnabled(), spanMetricReporter);
|
||||
if (!span.name.matches(skipPattern)) reporter.report(span);
|
||||
}
|
||||
}
|
|
@ -7,4 +7,4 @@ spring.cloud.config.password=configPassword
|
|||
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword@localhost:8082/eureka/
|
||||
|
||||
spring.sleuth.sampler.percentage=1.0
|
||||
spring.zipkin.base-url=http://zipkin
|
||||
spring.sleuth.web.skipPattern=(^cleanup.*)
|
||||
|
|
Loading…
Reference in New Issue