org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter Java Examples

The following examples show how to use org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BookServiceApplication.java    From tutorials with MIT License 6 votes vote down vote up
@Bean
public ZipkinSpanReporter makeZipkinSpanReporter() {
    return new ZipkinSpanReporter() {
        private HttpZipkinSpanReporter delegate;
        private String baseUrl;

        @Override
        public void report(Span span) {
            InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false);
            if (!(baseUrl != null && instance.getHomePageUrl().equals(baseUrl))) {
                baseUrl = instance.getHomePageUrl();
                delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter);
                if (!span.name.matches(skipPattern)) delegate.report(span);
            }
        }
    };
}
 
Example #2
Source File: GatewayApplication.java    From tutorials with MIT License 6 votes vote down vote up
@Bean
public ZipkinSpanReporter makeZipkinSpanReporter() {
    return new ZipkinSpanReporter() {
        private HttpZipkinSpanReporter delegate;
        private String baseUrl;

        @Override
        public void report(Span span) {
            InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false);
            if (!(baseUrl != null && instance.getHomePageUrl().equals(baseUrl))) {
                baseUrl = instance.getHomePageUrl();
                delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter);
                if (!span.name.matches(skipPattern)) delegate.report(span);
            }
            if (!span.name.matches(skipPattern)) delegate.report(span);
        }
    };
}
 
Example #3
Source File: RatingServiceApplication.java    From tutorials with MIT License 6 votes vote down vote up
@Bean
public ZipkinSpanReporter makeZipkinSpanReporter() {
    return new ZipkinSpanReporter() {
        private HttpZipkinSpanReporter delegate;
        private String baseUrl;

        @Override
        public void report(Span span) {
            InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false);
            if (!(baseUrl != null && instance.getHomePageUrl().equals(baseUrl))) {
                baseUrl = instance.getHomePageUrl();
                delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter);
                if (!span.name.matches(skipPattern)) delegate.report(span);
            }
            if (!span.name.matches(skipPattern)) delegate.report(span);
        }
    };
}
 
Example #4
Source File: HelloWorldApplication.java    From kubernetes-zipkin with Apache License 2.0 5 votes vote down vote up
@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));
        }
    };
}
 
Example #5
Source File: ZipkinKubernetesAutoConfiguration.java    From spring-cloud-kubernetes with Apache License 2.0 5 votes vote down vote up
@Bean
public ZipkinSpanReporter reporter(KubernetesClient client, KubernetesZipkinDiscoveryProperties discoveryProperties, SpanMetricReporter spanMetricReporter, ZipkinProperties zipkin) {
    String serviceName = discoveryProperties.getServiceName();
    String serviceNamespace = Utils.isNotNullOrEmpty(discoveryProperties.getServiceNamespace()) ? discoveryProperties.getServiceNamespace() : client.getNamespace();

    List<ServiceInstance> services = getInstances(client, serviceName, serviceNamespace);
    String serviceUrl = services.stream()
            .findFirst()
            .map(s -> s.getUri().toString())
            .orElse(null);

    return serviceUrl == null || serviceUrl.isEmpty()
            ? new NullZipkinSpanReporter()
            : new HttpZipkinSpanReporter(serviceUrl, zipkin.getFlushInterval(), zipkin.getCompression().isEnabled(), spanMetricReporter);
}