chore: bump version of spring-cloud-xxxx. Remove obsolete zipkin module.
This commit is contained in:
28
README.md
28
README.md
@@ -16,7 +16,6 @@
|
||||
- [Transparency](#transparency) *(it is transparent whether the code runs in or outside of Kubernetes)*
|
||||
- [Kubernetes Profile Autoconfiguration](#kubernetes-profile-autoconfiguration)
|
||||
- [Ribbon discovery in Kubernetes](#ribbon-discovery-in-kubernetes)
|
||||
- [Zipkin discovery in Kubernetes](#zipkin-discovery-in-kubernetes)
|
||||
- [ConfigMap Archaius Bridge](#configmap-archaius-bridge)
|
||||
|
||||
---
|
||||
@@ -527,33 +526,6 @@ Examples that are using this module for ribbon discovery are:
|
||||
Remark : The Ribbon discovery client can be disabled by setting this key within the application properties file
|
||||
`spring.cloud.kubernetes.ribbon.enabled=false`.
|
||||
|
||||
|
||||
### Zipkin discovery in Kubernetes
|
||||
|
||||
[](https://maven-badges.herokuapp.com/maven-central/org.springframework.cloud/spring-cloud-starter-kubernetes-zipkin/)
|
||||
[](http://www.javadoc.io/doc/org.springframework.cloud/spring-cloud-starter-kubernetes-zipkin)
|
||||
[](https://www.versioneye.com/java/org.springframework.cloud:spring-cloud-starter-kubernetes-zipkin/)
|
||||
|
||||
[Zipkin](https://github.com/openzipkin/zipkin) is a distributed tracing system which is supported by the project
|
||||
[Spring Cloud Sleuth](https://github.com/spring-cloud/spring-cloud-sleuth) which allows
|
||||
to collect traces or spans from microservice applications.
|
||||
|
||||
A Discovery client has been implemented top of Kubernetes in order to fetch the Zipkin service (e.g. `zipkin`). This
|
||||
client is provided by the [spring-cloud-kubernetes-zipkin](spring-cloud-kubernetes-zipkin/pom.xml) project that you
|
||||
can use by adding this starter to your maven pom file:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-zipkin</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
This works as an extension of the [spring-cloud-sleuth-zipkin](https://github.com/spring-cloud/spring-cloud-sleuth/tree/master/spring-cloud-sleuth-zipkin) project.
|
||||
The name of the Zipkin service and the target Kubernetes namespace/project where the service runs can be specified
|
||||
using the following `application.properties` properties:
|
||||
|
||||
```bash
|
||||
spring.cloud.kubernetes.zipkin.discovery.serviceName=my-zipkin
|
||||
spring.cloud.kubernetes.zipkin.discovery.serviceNamespace=tracing
|
||||
|
||||
8
pom.xml
8
pom.xml
@@ -59,9 +59,9 @@
|
||||
|
||||
<properties>
|
||||
<!-- Dependency Versions -->
|
||||
<spring-cloud-commons.version>1.2.3.RELEASE</spring-cloud-commons.version>
|
||||
<spring-cloud-netflix.version>1.3.2.RELEASE</spring-cloud-netflix.version>
|
||||
<spring-cloud-sleuth.version>1.2.2.RELEASE</spring-cloud-sleuth.version>
|
||||
<spring-cloud-commons.version>1.3.5.RELEASE</spring-cloud-commons.version>
|
||||
<spring-cloud-netflix.version>1.4.6.RELEASE</spring-cloud-netflix.version>
|
||||
<spring-cloud-sleuth.version>1.3.5.RELEASE</spring-cloud-sleuth.version>
|
||||
|
||||
<!-- Maven Plugin Versions -->
|
||||
<maven-compiler-plugin.version>3.5</maven-compiler-plugin.version>
|
||||
@@ -78,13 +78,11 @@
|
||||
<module>spring-cloud-kubernetes-config</module>
|
||||
<module>spring-cloud-kubernetes-discovery</module>
|
||||
<module>spring-cloud-kubernetes-ribbon</module>
|
||||
<module>spring-cloud-kubernetes-zipkin</module>
|
||||
<module>spring-cloud-kubernetes-hystrix</module>
|
||||
<module>spring-cloud-kubernetes-archaius</module>
|
||||
<module>spring-cloud-starter-kubernetes</module>
|
||||
<module>spring-cloud-starter-kubernetes-config</module>
|
||||
<module>spring-cloud-starter-kubernetes-netflix</module>
|
||||
<module>spring-cloud-starter-kubernetes-zipkin</module>
|
||||
<module>spring-cloud-starter-kubernetes-ribbon</module>
|
||||
<module>spring-cloud-starter-kubernetes-all</module>
|
||||
<module>spring-cloud-kubernetes-examples</module>
|
||||
|
||||
@@ -87,10 +87,6 @@
|
||||
</dependency>
|
||||
|
||||
<!-- Zipkin -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-zipkin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
|
||||
@@ -21,8 +21,6 @@ import org.apache.commons.logging.Log;
|
||||
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;
|
||||
|
||||
@@ -5,6 +5,9 @@ spring:
|
||||
sleuth:
|
||||
sampler:
|
||||
percentage: 1.0
|
||||
zipkin:
|
||||
# Assuming that zipkinserver is the service name of zipkin server.
|
||||
baseUrl: http://zipkinserver
|
||||
|
||||
sample:
|
||||
zipkin:
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 to the original authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>0.2.1.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-zipkin</artifactId>
|
||||
<name>Spring Cloud Kubernetes :: Zipkin</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-discovery</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-commons</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-context</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 to the original authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.zipkin;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("spring.cloud.kubernetes.zipkin.discovery")
|
||||
public class KubernetesZipkinDiscoveryProperties {
|
||||
|
||||
private boolean enabled = true;
|
||||
private String serviceName = "zipkin";
|
||||
private String serviceNamespace;
|
||||
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public String getServiceNamespace() {
|
||||
return serviceNamespace;
|
||||
}
|
||||
|
||||
public void setServiceNamespace(String serviceNamespace) {
|
||||
this.serviceNamespace = serviceNamespace;
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 to the original authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.zipkin;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.Endpoints;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.utils.Utils;
|
||||
import org.springframework.cloud.kubernetes.discovery.KubernetesServiceInstance;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.sleuth.metric.SpanMetricReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.DefaultZipkinRestTemplateCustomizer;
|
||||
import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinProperties;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import zipkin.Span;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(KubernetesZipkinDiscoveryProperties.class)
|
||||
@ConditionalOnProperty(value = "spring.cloud.kubernetes.zipkin.discovery.enabled", matchIfMissing = true)
|
||||
@AutoConfigureBefore(ZipkinAutoConfiguration.class)
|
||||
public class ZipkinKubernetesAutoConfiguration {
|
||||
|
||||
|
||||
@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(restTemplateWithCompression(), serviceUrl, zipkin.getFlushInterval(), spanMetricReporter);
|
||||
}
|
||||
|
||||
private static List<ServiceInstance> getInstances(KubernetesClient client, String name, String namespace) {
|
||||
Assert.notNull(name, "[Assertion failed] - the service name must not be null");
|
||||
|
||||
return Optional.ofNullable(client.endpoints().inNamespace(namespace).withName(name).get())
|
||||
.orElse(new Endpoints())
|
||||
.getSubsets()
|
||||
.stream()
|
||||
.flatMap(s -> s.getAddresses().stream().map(a -> (ServiceInstance) new KubernetesServiceInstance(name, a ,s.getPorts().stream().findFirst().orElseThrow(IllegalStateException::new), false)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
static final class NullZipkinSpanReporter implements ZipkinSpanReporter {
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private RestTemplate restTemplateWithCompression() {
|
||||
ZipkinProperties zipkinProperties = new ZipkinProperties();
|
||||
zipkinProperties.getCompression().setEnabled(true);
|
||||
return restTemplate(zipkinProperties);
|
||||
}
|
||||
|
||||
private RestTemplate restTemplate(ZipkinProperties zipkinProperties) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
new DefaultZipkinRestTemplateCustomizer(zipkinProperties).customize(restTemplate);
|
||||
return restTemplate;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.kubernetes.zipkin.ZipkinKubernetesAutoConfiguration
|
||||
@@ -61,16 +61,6 @@
|
||||
<artifactId>spring-cloud-kubernetes-hystrix</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-zipkin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 to the original authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>0.2.1.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-zipkin</artifactId>
|
||||
<name>Spring Cloud Kubernetes :: Starter :: Zipkin</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-zipkin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
Reference in New Issue
Block a user