Applied checkstyle
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,8 @@ import java.net.InetAddress;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import zipkin2.Endpoint;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
@@ -29,10 +31,9 @@ import org.springframework.cloud.commons.util.InetUtilsProperties;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
import zipkin2.Endpoint;
|
||||
|
||||
/**
|
||||
* {@link EndpointLocator} implementation that:
|
||||
* {@link EndpointLocator} implementation that.
|
||||
*
|
||||
* <ul>
|
||||
* <li><b>serviceName</b> - from {@link ServerProperties} or {@link Registration}</li>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -50,12 +50,12 @@ import org.springframework.util.Assert;
|
||||
* multiple tracing systems on the classpath.
|
||||
*
|
||||
* Needs to be auto-configured before {@link ZipkinAutoConfiguration} in order to create a
|
||||
* {@link Reporter<Span> span reporter} if needed.
|
||||
* {@link Reporter span reporter} if needed.
|
||||
*
|
||||
* @author Tim Ysewyn
|
||||
* @since 2.1.0
|
||||
* @see ZipkinAutoConfiguration
|
||||
* @deprecated
|
||||
* @deprecated left for backward compatibility
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = { "spring.sleuth.enabled",
|
||||
@@ -67,6 +67,12 @@ public class ZipkinBackwardsCompatibilityAutoConfiguration {
|
||||
/**
|
||||
* Reporter that is depending on a {@link Sender} bean which is created in another
|
||||
* auto-configuration than {@link ZipkinAutoConfiguration}.
|
||||
* @param reporterMetrics metrics
|
||||
* @param zipkin zipkin properties
|
||||
* @param spanBytesEncoder encoder
|
||||
* @param beanFactory Spring's Bean Factory
|
||||
* @return span reporter
|
||||
* @deprecated left for backwards compatibility
|
||||
*/
|
||||
@Bean
|
||||
@Conditional(BackwardsCompatibilityCondition.class)
|
||||
@@ -84,8 +90,10 @@ public class ZipkinBackwardsCompatibilityAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Only used for creating a reporter bean with the method above
|
||||
* @deprecated
|
||||
* Only used for creating a reporter bean with the method above.
|
||||
* @param zipkinProperties zipkin properties
|
||||
* @return bytes encoder
|
||||
* @deprecated left for backwards compatibility
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@@ -97,7 +105,8 @@ public class ZipkinBackwardsCompatibilityAutoConfiguration {
|
||||
/**
|
||||
* Deprecated because this is moved to {@link TraceAutoConfiguration}. Left for
|
||||
* backwards compatibility reasons.
|
||||
* @deprecated
|
||||
* @return reporter metrics
|
||||
* @deprecated left for backwards compatibility
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.sleuth.zipkin2;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Load balancing strategy for picking a Zipkin instance
|
||||
* Load balancing strategy for picking a Zipkin instance.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.3.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin2;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import zipkin2.codec.SpanBytesEncoder;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Zipkin settings
|
||||
* Zipkin settings.
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
* @since 1.0.0
|
||||
@@ -32,23 +32,23 @@ public class ZipkinProperties {
|
||||
/**
|
||||
* URL of the zipkin query server instance. You can also provide the service id of the
|
||||
* Zipkin server if Zipkin's registered in service discovery (e.g.
|
||||
* http://zipkinserver/)
|
||||
* http://zipkinserver/).
|
||||
*/
|
||||
private String baseUrl = "http://localhost:9411/";
|
||||
|
||||
/**
|
||||
* If set to {@code false}, will treat the {@link ZipkinProperties#baseUrl} as a URL
|
||||
* always
|
||||
* always.
|
||||
*/
|
||||
private Boolean discoveryClientEnabled;
|
||||
|
||||
/**
|
||||
* Enables sending spans to Zipkin
|
||||
* Enables sending spans to Zipkin.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* Timeout in seconds before pending spans will be sent in batches to Zipkin
|
||||
* Timeout in seconds before pending spans will be sent in batches to Zipkin.
|
||||
*/
|
||||
private int messageTimeout = 1;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ZipkinProperties {
|
||||
private SpanBytesEncoder encoder = SpanBytesEncoder.JSON_V2;
|
||||
|
||||
/**
|
||||
* Configuration related to compressions of spans sent to Zipkin
|
||||
* Configuration related to compressions of spans sent to Zipkin.
|
||||
*/
|
||||
private Compression compression = new Compression();
|
||||
|
||||
@@ -71,14 +71,26 @@ public class ZipkinProperties {
|
||||
return this.locator;
|
||||
}
|
||||
|
||||
public void setLocator(Locator locator) {
|
||||
this.locator = locator;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return this.baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getDiscoveryClientEnabled() {
|
||||
return this.discoveryClientEnabled;
|
||||
}
|
||||
@@ -91,36 +103,24 @@ public class ZipkinProperties {
|
||||
return this.messageTimeout;
|
||||
}
|
||||
|
||||
public Compression getCompression() {
|
||||
return this.compression;
|
||||
}
|
||||
|
||||
public Service getService() {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setMessageTimeout(int messageTimeout) {
|
||||
this.messageTimeout = messageTimeout;
|
||||
}
|
||||
|
||||
public Compression getCompression() {
|
||||
return this.compression;
|
||||
}
|
||||
|
||||
public void setCompression(Compression compression) {
|
||||
this.compression = compression;
|
||||
}
|
||||
|
||||
public void setService(Service service) {
|
||||
this.service = service;
|
||||
public Service getService() {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
public void setLocator(Locator locator) {
|
||||
this.locator = locator;
|
||||
public void setService(Service service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public SpanBytesEncoder getEncoder() {
|
||||
@@ -131,7 +131,7 @@ public class ZipkinProperties {
|
||||
this.encoder = encoder;
|
||||
}
|
||||
|
||||
/** When enabled, spans are gzipped before sent to the zipkin server */
|
||||
/** When enabled, spans are gzipped before sent to the zipkin server. */
|
||||
public static class Compression {
|
||||
|
||||
private boolean enabled = false;
|
||||
@@ -148,13 +148,13 @@ public class ZipkinProperties {
|
||||
|
||||
/**
|
||||
* When set will override the default {@code spring.application.name} value of the
|
||||
* service id
|
||||
* service id.
|
||||
*/
|
||||
public static class Service {
|
||||
|
||||
/**
|
||||
* The name of the service, from which the Span was sent via HTTP, that should
|
||||
* appear in Zipkin
|
||||
* appear in Zipkin.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
@@ -185,9 +185,12 @@ public class ZipkinProperties {
|
||||
this.discovery = discovery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discovery Locator properties.
|
||||
*/
|
||||
public static class Discovery {
|
||||
|
||||
/** Enabling of locating the host name via service discovery */
|
||||
/** Enabling of locating the host name via service discovery. */
|
||||
private boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,4 +48,4 @@ class LoadBalancerClientZipkinLoadBalancer implements ZipkinLoadBalancer {
|
||||
return URI.create(this.zipkinProperties.getBaseUrl());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,12 +20,6 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import zipkin2.Call;
|
||||
import zipkin2.Callback;
|
||||
import zipkin2.CheckResult;
|
||||
@@ -35,6 +29,12 @@ import zipkin2.codec.Encoding;
|
||||
import zipkin2.reporter.BytesMessageEncoder;
|
||||
import zipkin2.reporter.Sender;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static zipkin2.codec.SpanBytesEncoder.JSON_V2;
|
||||
|
||||
final class RestTemplateSender extends Sender {
|
||||
@@ -49,6 +49,11 @@ final class RestTemplateSender extends Sender {
|
||||
|
||||
final BytesMessageEncoder messageEncoder;
|
||||
|
||||
/**
|
||||
* close is typically called from a different thread.
|
||||
*/
|
||||
transient boolean closeCalled;
|
||||
|
||||
RestTemplateSender(RestTemplate restTemplate, String baseUrl,
|
||||
BytesEncoder<Span> encoder) {
|
||||
this.restTemplate = restTemplate;
|
||||
@@ -89,15 +94,11 @@ final class RestTemplateSender extends Sender {
|
||||
return encoding().listSizeInBytes(spans);
|
||||
}
|
||||
|
||||
/**
|
||||
* close is typically called from a different thread
|
||||
*/
|
||||
transient boolean closeCalled;
|
||||
|
||||
@Override
|
||||
public Call<Void> sendSpans(List<byte[]> encodedSpans) {
|
||||
if (this.closeCalled)
|
||||
if (this.closeCalled) {
|
||||
throw new IllegalStateException("close");
|
||||
}
|
||||
return new HttpPostCall(this.messageEncoder.encode(encodedSpans));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,11 @@ package org.springframework.cloud.sleuth.zipkin2.sender;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.kafka.common.serialization.ByteArraySerializer;
|
||||
import zipkin2.reporter.Sender;
|
||||
import zipkin2.reporter.kafka11.KafkaSender;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -29,8 +33,6 @@ import org.springframework.cloud.sleuth.zipkin2.ZipkinAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import zipkin2.reporter.Sender;
|
||||
import zipkin2.reporter.kafka11.KafkaSender;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(ByteArraySerializer.class)
|
||||
@@ -43,6 +45,17 @@ class ZipkinKafkaSenderConfiguration {
|
||||
@Value("${spring.zipkin.kafka.topic:zipkin}")
|
||||
private String topic;
|
||||
|
||||
static String join(List<?> parts) {
|
||||
StringBuilder to = new StringBuilder();
|
||||
for (int i = 0, length = parts.size(); i < length; i++) {
|
||||
to.append(parts.get(i));
|
||||
if (i + 1 < length) {
|
||||
to.append(',');
|
||||
}
|
||||
}
|
||||
return to.toString();
|
||||
}
|
||||
|
||||
@Bean(ZipkinAutoConfiguration.SENDER_BEAN_NAME)
|
||||
Sender kafkaSender(KafkaProperties config) {
|
||||
Map<String, Object> properties = config.buildProducerProperties();
|
||||
@@ -56,15 +69,4 @@ class ZipkinKafkaSenderConfiguration {
|
||||
return KafkaSender.newBuilder().topic(this.topic).overrides(properties).build();
|
||||
}
|
||||
|
||||
static String join(List<?> parts) {
|
||||
StringBuilder to = new StringBuilder();
|
||||
for (int i = 0, length = parts.size(); i < length; i++) {
|
||||
to.append(parts.get(i));
|
||||
if (i + 1 < length) {
|
||||
to.append(',');
|
||||
}
|
||||
}
|
||||
return to.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin2.sender;
|
||||
|
||||
import zipkin2.reporter.Sender;
|
||||
import zipkin2.reporter.amqp.RabbitMQSender;
|
||||
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
|
||||
@@ -25,8 +28,6 @@ import org.springframework.cloud.sleuth.zipkin2.ZipkinAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import zipkin2.reporter.Sender;
|
||||
import zipkin2.reporter.amqp.RabbitMQSender;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(CachingConnectionFactory.class)
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.net.URISyntaxException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import zipkin2.reporter.Sender;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -40,7 +42,6 @@ import org.springframework.web.client.RequestCallback;
|
||||
import org.springframework.web.client.ResponseExtractor;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import zipkin2.reporter.Sender;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(name = ZipkinAutoConfiguration.SENDER_BEAN_NAME)
|
||||
@@ -60,6 +61,16 @@ class ZipkinRestTemplateSenderConfiguration {
|
||||
zipkin.getEncoder());
|
||||
}
|
||||
|
||||
@Bean
|
||||
ZipkinUrlExtractor zipkinUrlExtractor(final ZipkinLoadBalancer zipkinLoadBalancer) {
|
||||
return new ZipkinUrlExtractor() {
|
||||
@Override
|
||||
public URI zipkinUrl(ZipkinProperties zipkinProperties) {
|
||||
return zipkinLoadBalancer.instance();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingClass("org.springframework.cloud.client.loadbalancer.LoadBalancerClient")
|
||||
static class DefaultZipkinUrlExtractorConfiguration {
|
||||
@@ -110,15 +121,16 @@ class ZipkinRestTemplateSenderConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
ZipkinUrlExtractor zipkinUrlExtractor(final ZipkinLoadBalancer zipkinLoadBalancer) {
|
||||
return new ZipkinUrlExtractor() {
|
||||
@Override
|
||||
public URI zipkinUrl(ZipkinProperties zipkinProperties) {
|
||||
return zipkinLoadBalancer.instance();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal interface to provide a way to retrieve Zipkin URI. If there's no discovery
|
||||
* client then this value will be taken from the properties. Otherwise host will be
|
||||
* assumed to be a service id.
|
||||
*/
|
||||
interface ZipkinUrlExtractor {
|
||||
|
||||
URI zipkinUrl(ZipkinProperties zipkinProperties);
|
||||
|
||||
}
|
||||
|
||||
@@ -168,17 +180,6 @@ class ZipkinRestTemplateWrapper extends RestTemplate {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal interface to provide a way to retrieve Zipkin URI. If there's no discovery
|
||||
* client then this value will be taken from the properties. Otherwise host will be
|
||||
* assumed to be a service id.
|
||||
*/
|
||||
interface ZipkinUrlExtractor {
|
||||
|
||||
URI zipkinUrl(ZipkinProperties zipkinProperties);
|
||||
|
||||
}
|
||||
|
||||
class NoOpZipkinLoadBalancer implements ZipkinLoadBalancer {
|
||||
|
||||
private final ZipkinProperties zipkinProperties;
|
||||
@@ -192,4 +193,4 @@ class NoOpZipkinLoadBalancer implements ZipkinLoadBalancer {
|
||||
return URI.create(this.zipkinProperties.getBaseUrl());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,9 +19,15 @@ package org.springframework.cloud.sleuth.zipkin2.sender;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.context.annotation.ImportSelector;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
|
||||
/**
|
||||
* Import selector depending on the sender type.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ZipkinSenderConfigurationImportSelector implements ImportSelector {
|
||||
|
||||
static final Map<String, String> MAPPINGS;
|
||||
@@ -36,11 +42,6 @@ public class ZipkinSenderConfigurationImportSelector implements ImportSelector {
|
||||
MAPPINGS = Collections.unmodifiableMap(mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
return MAPPINGS.values().toArray(new String[0]);
|
||||
}
|
||||
|
||||
static String getType(String configurationClassName) {
|
||||
for (Map.Entry<String, String> entry : MAPPINGS.entrySet()) {
|
||||
if (entry.getValue().equals(configurationClassName)) {
|
||||
@@ -51,4 +52,9 @@ public class ZipkinSenderConfigurationImportSelector implements ImportSelector {
|
||||
"Unknown configuration class " + configurationClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
return MAPPINGS.values().toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.sleuth.zipkin2.sender;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties for Zipkin sender
|
||||
* Properties for Zipkin sender.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.3.1
|
||||
@@ -28,7 +28,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
public class ZipkinSenderProperties {
|
||||
|
||||
/**
|
||||
* Means of sending spans to Zipkin
|
||||
* Means of sending spans to Zipkin.
|
||||
*/
|
||||
private SenderType type;
|
||||
|
||||
@@ -40,9 +40,25 @@ public class ZipkinSenderProperties {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Types of a sender.
|
||||
*/
|
||||
public enum SenderType {
|
||||
|
||||
RABBIT, KAFKA, WEB
|
||||
/**
|
||||
* RabbitMQ sender.
|
||||
*/
|
||||
RABBIT,
|
||||
|
||||
/**
|
||||
* Kafka sender.
|
||||
*/
|
||||
KAFKA,
|
||||
|
||||
/**
|
||||
* HTTP based sender.
|
||||
*/
|
||||
WEB
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Auto Configuration
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.sleuth.zipkin2.ZipkinAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.zipkin2.ZipkinBackwardsCompatibilityAutoConfiguration
|
||||
org.springframework.cloud.sleuth.zipkin2.ZipkinBackwardsCompatibilityAutoConfiguration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
@@ -42,6 +43,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public class DefaultEndpointLocatorConfigurationTest {
|
||||
|
||||
public static final byte[] ADDRESS1234 = { 1, 2, 3, 4 };
|
||||
|
||||
Environment environment = new MockEnvironment();
|
||||
|
||||
@Test
|
||||
public void endpointLocatorShouldDefaultToServerPropertiesEndpointLocator() {
|
||||
ConfigurableApplicationContext ctxt = new SpringApplication(
|
||||
@@ -101,70 +106,6 @@ public class DefaultEndpointLocatorConfigurationTest {
|
||||
ctxt.close();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
public static class EmptyConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
public static class ConfigurationWithRegistration {
|
||||
|
||||
@Bean
|
||||
public Registration getRegistration() {
|
||||
return new Registration() {
|
||||
@Override
|
||||
public String getServiceId() {
|
||||
return "from-registration";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
public static class ConfigurationWithCustomLocator {
|
||||
|
||||
static EndpointLocator locator = Mockito.mock(EndpointLocator.class);
|
||||
|
||||
@Bean
|
||||
public EndpointLocator getEndpointLocator() {
|
||||
return locator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final byte[] ADDRESS1234 = { 1, 2, 3, 4 };
|
||||
|
||||
Environment environment = new MockEnvironment();
|
||||
|
||||
@Test
|
||||
public void portDefaultsTo8080() throws UnknownHostException {
|
||||
DefaultEndpointLocator locator = new DefaultEndpointLocator(null,
|
||||
@@ -236,4 +177,64 @@ public class DefaultEndpointLocatorConfigurationTest {
|
||||
return mocked;
|
||||
}
|
||||
|
||||
}
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
public static class EmptyConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
public static class ConfigurationWithRegistration {
|
||||
|
||||
@Bean
|
||||
public Registration getRegistration() {
|
||||
return new Registration() {
|
||||
@Override
|
||||
public String getServiceId() {
|
||||
return "from-registration";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
public static class ConfigurationWithCustomLocator {
|
||||
|
||||
static EndpointLocator locator = Mockito.mock(EndpointLocator.class);
|
||||
|
||||
@Bean
|
||||
public EndpointLocator getEndpointLocator() {
|
||||
return locator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
/**
|
||||
* Not using {@linkplain SpringBootTest} as we need to change properties per test.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ZipkinAutoConfigurationTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,6 +28,7 @@ import org.awaitility.Awaitility;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -137,4 +138,4 @@ public class ZipkinDiscoveryClientTests {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,10 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin2;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,18 +17,20 @@
|
||||
package org.springframework.cloud.sleuth.zipkin2.sender;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import zipkin2.Call;
|
||||
import zipkin2.Endpoint;
|
||||
import zipkin2.Span;
|
||||
import zipkin2.codec.Encoding;
|
||||
import zipkin2.codec.SpanBytesEncoder;
|
||||
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static zipkin2.codec.SpanBytesEncoder.JSON_V2;
|
||||
@@ -52,7 +54,10 @@ public class RestTemplateSenderTest {
|
||||
RestTemplateSender sender = new RestTemplateSender(new RestTemplate(), this.endpoint,
|
||||
JSON_V2);
|
||||
|
||||
/** Tests that json is not manipulated as a side-effect of using rest template. */
|
||||
/**
|
||||
* Tests that json is not manipulated as a side-effect of using rest template.
|
||||
* @throws Exception when span sending or receiving fails
|
||||
*/
|
||||
@Test
|
||||
public void jsonIsNormal() throws Exception {
|
||||
this.server.enqueue(new MockResponse());
|
||||
|
||||
Reference in New Issue
Block a user