zipkin
zipkin copied to clipboard
Options for Service Discovery
We get occasionally asked about service discovery and registration etc. Please reply back with what you are using if anything to register zipkin in something like consul.
FINN.no used to run Zipkin behind haproxy (dynamically configured) when I was working there, I think they have moved to Kubernetes now, which has its own service discovery and registration. Zipkin pretty much scales out of the box, you don't have to put much thought into it.
We use well known names, DNS for HTTP and zipkin for our kinesis queue name
My client is using Spring Cloud discovery to register Zipkin instances in Zookeeper.
My client is using Spring Cloud discovery to register Zipkin instances in Zookeeper.
Is this via a custom build of zipkin-server?
Exactly : @EnableDiscoveryClient with the right configuration.
Kubernetes services helm example. Other services can then just access zipkin at http://zipkin:9411
I register zipkin server to spring cloud eureka server, for other services to discover, and also get configuation from spring cloud config server. We use it by custom maven build, the spring boot version is 1.5.X. When I use spring boot 2.0 build, the UI displays error: "Cannot load service names: No message available"
We repeatedly get requests about @EnableDiscoveryClient or @EnableEurekaClient I'd like to try and see if there is an alternative way to register with eureka that doesn't imply literally modifying the main class. If we can do so with auto-configuration instead, it might be worthwhile posting how.
interesting.. https://github.com/spring-cloud/spring-cloud-commons/pull/245/files
https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#registering-with-eureka seems we can make an example integration..
here's a way to bolt-on eureka to an existing zipkin server without modifying it.
This requires that you have maven installed. You don't need to do any custom code as it is 100% packaging.
# get normal zipkin server
$ curl -sSL https://zipkin.io/quickstart.sh | bash -s
# build the eureka module
$ mvn clean install
# rename the jar so it is easier
$ mv target/eureka-1.0-SNAPSHOT-module.jar eureka.jar
# start zipkin which now has eureka support
$ java -Dloader.path='eureka.jar,eureka.jar!/lib' -cp zipkin.jar org.springframework.boot.loader.PropertiesLauncher
Here's the only file you need:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>io.zipkin.custom</groupId>
<artifactId>eureka</artifactId>
<version>1.0-SNAPSHOT</version>
<description>Example module that adds Eureka to an existing Zipkin</description>
<properties>
<!-- make sure this matches zipkin-server's spring boot version -->
<spring-boot.version>2.1.1.RELEASE</spring-boot.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<!-- This makes sure versions are aligned properly -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- this is the thing that adds Eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.2.RELEASE</version>
<exclusions>
<!-- zipkin already has this -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<layoutFactory implementation="zipkin.layout.ZipkinLayoutFactory">
<name>custom</name>
</layoutFactory>
<classifier>module</classifier>
<!-- exclude dependencies already packaged in zipkin-server. -->
<!-- https://github.com/spring-projects/spring-boot/issues/3426 transitive exclude doesn't work -->
<excludeGroupIds>io.zipkin.zipkin2,io.zipkin.reporter2,org.springframework.boot,org.springframework,com.fasterxml.jackson.core,com.google.auto.value,com.google.gson,com.google.guava,org.slf4j
</excludeGroupIds>
</configuration>
<dependencies>
<dependency>
<groupId>io.zipkin.layout</groupId>
<artifactId>zipkin-layout-factory</artifactId>
<version>0.0.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
https://twitter.com/toongeens pointed me to this as well https://github.com/gliderlabs/registrator
I used the above bolt-on to answer a related BASIC auth question. This is the main way to add things to the server without recompiling it https://github.com/openzipkin/zipkin/issues/782#issuecomment-433306013
Awesome Adrian, this is the first time I've ever bookmarked a GitHub issue
@adriancole
Thanks for the script
A minor update to the script would register zipkin under the service id zipkin-server instead of unknown. For this we need to add -Dspring.application.name=zipkin-server when launching zipkin.jar
The final line in the script would be
java -Dloader.path='eureka.jar,eureka.jar!/lib' -Dspring.application.name=zipkin-server -cp zipkin.jar org.springframework.boot.loader.PropertiesLauncher
I merged everything to a single script including pom.xml
Now first time, we need to run this (which downloads zipkin & builds eureka.jar)
#!/bin/sh
# get normal zipkin server
curl -sSL https://zipkin.io/quickstart.sh | bash -s
# Write pom.xml thats responsible for generating eureka.jar
cat << 'EOF' > pom.xml
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>io.zipkin.custom</groupId>
<artifactId>eureka</artifactId>
<version>1.0-SNAPSHOT</version>
<description>Example module that adds Eureka to an existing Zipkin</description>
<properties>
<!-- make sure this matches zipkin-server's spring boot version -->
<spring-boot.version>2.3.0.RELEASE</spring-boot.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<!-- This makes sure versions are aligned properly -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- this is the thing that adds Eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.2.2.RELEASE</version>
<exclusions>
<!-- zipkin already has this -->
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<layoutFactory implementation="zipkin.layout.ZipkinLayoutFactory">
<name>zipkin</name>
</layoutFactory>
<classifier>module</classifier>
<!-- exclude dependencies already packaged in zipkin-server. -->
<!-- https://github.com/spring-projects/spring-boot/issues/3426 transitive exclude doesn't work -->
<excludeGroupIds>io.zipkin.zipkin2,io.zipkin.reporter2,org.springframework.boot,com.fasterxml.jackson.core,com.google.auto.value,com.google.gson,com.google.guava,org.slf4j
</excludeGroupIds>
</configuration>
<dependencies>
<dependency>
<groupId>io.zipkin.layout</groupId>
<artifactId>zipkin-layout-factory</artifactId>
<version>0.0.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
EOF
# Build eureka module
mvn clean install
# Rename the jar so it is easier
mv target/eureka-1.0-SNAPSHOT-module.jar eureka.jar
Subsequently, we need to run just this to start & register server with eureka
#!/bin/sh
# Start zipkin which now has eureka support
java -Dloader.path='eureka.jar,eureka.jar!/lib' -Dspring.boot.enableautoconfiguration=true -Dspring.application.name=zipkin-server -cp zipkin.jar org.springframework.boot.loader.PropertiesLauncher
thanks tons!
I got https://github.com/openzipkin/zipkin/issues/1870#issuecomment-470068636 working again, but it is a bit of a dependency mess. hoping we can leverage work of armeria here to avoid this and let people opt-in for bootstrap service registration https://github.com/line/armeria/pull/2701
could people here please mention what if anything you configure in eureka besides the service name and the eureka host address? With recent developments in Armeria, we may be able to do this out-of-box. I presume the only thing desired here is registering the zipkin http listener.
cc @minwoox
The reason I'm asking is that I'm told if we internally use EurekaUpdatingListenerBuilder, we can register on startup, even in zipkin-slim, with no dependencies at all.
A minor update to the script would register zipkin under the service id zipkin-server instead of unknown. For this we need to add -Dspring.application.name=zipkin-server when launching zipkin.jar
For this we can do something like in Armeria:
ServerBuilder sb = ...;
sb.serverListener(EurekaUpdatingListener.builder(eurekaUri)
.instanceId("zipkin-server")
.build());
The reason I'm asking is that I'm told if we internally use
EurekaUpdatingListenerBuilder, we can register on startup, even in zipkin-slim, with no dependencies at all.
Note that the no-dependencies scenario no longer applies, see https://armeria.dev/docs/server-service-registration. Wondering if this could go in the fat-exec jar ?
maybe depends on how big it is and if we want to keep supporting it in the rare but possible case that armeria removes support for it. Another way is to package in contrib something like this that can be added to the server using the MODULE_OPTS we use for things like zipkin-aws? https://github.com/adriancole/zipkin-security
We still do not need extra dependencies. https://github.com/line/armeria/blob/master/eureka/build.gradle You can see that there's no dependencies needed.
Ah, we made the separate module for eureka which just uses the dependencies that Armeria uses.
The jar looks like it is only 54k so no biggie. Now we are down to configuration (and relevance)
While URL and instance ID are minimal, there are other properties
EurekaUpdatingListener.builder("https://eureka.com:8001/eureka/v2");
.instanceId("i-00000000")
.setHostname("armeria.service.1")
// If ipAddr is not specified, it's automatically filled
// using SystemInfo.defaultNonLoopbackIpV4Address().
.ipAddr("192.168.10.10")
.vipAddress("armeria.service.com:8080");
For example, we had a lot of requests for eureka and some for nacos. Not sure how popular eureka is still. If it is, we can consider designing an integration either bundled or opt-in.
copying @XuefengChen @george24601 @chuguoren @charims @zoidbergwill @ezraroi @thekalinga @zerocode @lumiseven who 👍 this and @MaciejGawel @Jungle666 who mentioned this in other issues.
If you want eureka, please thumbs up this comment if you want this in the default server. If you don't reply back otherwise, the config will be limited to hard-coding the instanceId to "zipkin-server" and activated by a variable like EUREKA_URL
Note that if eureka itself becomes a canceled technology, or armeria stops supporting it, so would we.
note: It has been over 2 weeks and no one has thumbs upped my comment or replied persistently. Zipkin is a volunteer community and we only add features people will use as they cost work and attention. Our time to implement and support this will be far more effort than the time requested to even thumbs up or reply if EUREKA_URL will work. If no one replies in the next week, I'll close out the ticket and cite this next time asked.
@adriancole please add this to zipkin server. We are heavy on eureka server and this will help us a lot.
@asif-rashid thanks for the feedback. If the only configuration for the server was EUREKA_URL and the instance ID set to "zipkin-server" or simply "zipkin" would this be good enough for your site?
Yes, this should work for us.
@codefromthecrypt I wish I've seen this thread a few months ago and voted for integration. Anyway, thanks for the provided workarounds and your efforts.