Refactor docker compose so default launches everything
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
<module>spring-cloud-sleuth-sample-messaging</module>
|
||||
<module>spring-cloud-sleuth-sample-ribbon</module>
|
||||
<module>spring-cloud-sleuth-sample-zipkin</module>
|
||||
<module>spring-cloud-sleuth-sample-zipkin-stream</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM springio/java8
|
||||
RUN chmod 777 -R /tmp
|
||||
VOLUME /tmp
|
||||
VOLUME /app
|
||||
EXPOSE 9411 8000
|
||||
RUN groupadd -g 1000 spring
|
||||
RUN useradd -u 1000 -g 1000 -ms /bin/bash spring
|
||||
VOLUME /home/spring
|
||||
ENV HOME /home/spring
|
||||
USER spring
|
||||
WORKDIR /app/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream
|
||||
CMD ["../../mvnw", "spring-boot:run"]
|
||||
@@ -0,0 +1,39 @@
|
||||
# Running a Zipkin Query Server
|
||||
|
||||
There are 4 parts to Zipkin: the instrumented client apps, the web UI, the backend database and the query server. The database for this implementation is MySQL.
|
||||
|
||||
## Zipkin Services
|
||||
|
||||
Run this app using the docker-compose provided.
|
||||
|
||||
```
|
||||
$ docker-compose build zipkin
|
||||
$ docker-compose up
|
||||
...
|
||||
```
|
||||
|
||||
and test it
|
||||
|
||||
```
|
||||
$ curl localhost:9411/api/v1/services
|
||||
["zipkin-query"]
|
||||
```
|
||||
|
||||
The app might fail to start if mysql is not available when it needs it. If that happens you can just start it separately: just keep running `docker-compose up` until it works.
|
||||
|
||||
|
||||
## Instrumenting Apps
|
||||
|
||||
Depend on [Spring Cloud Sleuth Stream](https://github.com/spring-cloud-spring-cloud-sleuth) and the rabbit binder (`spring-cloud-starter-stream-rabbit`).
|
||||
|
||||
Once the apps start publishing spans they will appear in the span store as well.
|
||||
|
||||
## Running in an IDE
|
||||
|
||||
You can run this app in an IDE and still use docker-compose to create the middleware:
|
||||
|
||||
```
|
||||
$ docker-compose up rabbitmq mysql
|
||||
```
|
||||
|
||||
The web UI cannot access the docker host though, so you have to run that separately, or just test against the query server directly on port 9411.
|
||||
@@ -0,0 +1,38 @@
|
||||
mysql:
|
||||
image: mysql
|
||||
ports:
|
||||
- 3306:3306
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=root
|
||||
- MYSQL_DATABASE=test
|
||||
rabbitmq:
|
||||
image: rabbitmq:management
|
||||
expose:
|
||||
- 5672
|
||||
ports:
|
||||
- 5672:5672
|
||||
- 15672:15672
|
||||
zipkin:
|
||||
build: .
|
||||
volumes:
|
||||
- ../..:/app
|
||||
- ~:/home/spring
|
||||
environment:
|
||||
- MYSQL_HOST=mysql
|
||||
- RABBIT_HOST=rabbitmq
|
||||
expose:
|
||||
- 9411
|
||||
ports:
|
||||
- 9411:9411
|
||||
links:
|
||||
- mysql
|
||||
- rabbitmq
|
||||
web:
|
||||
image: openzipkin/zipkin-web:1.25.3
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
- TRANSPORT_TYPE=http
|
||||
- WEB_LOG_LEVEL=DEBUG
|
||||
links:
|
||||
- zipkin:query
|
||||
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<artifactId>spring-cloud-sleuth-sample-zipkin-stream</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>spring-cloud-sleuth-sample-zipkin-stream</name>
|
||||
<description>Spring Boot Zipkin Server</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-samples</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<docker.image.prefix>springio</docker.image.prefix>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<zipkin-java.version>0.1.0</zipkin-java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-jmx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-binder-local</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<classifier>exec</classifier>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
package example;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.sleuth.zipkin.stream.EnableZipkinStreamServer;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableZipkinStreamServer
|
||||
public class ZipkinStreamServerApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(ZipkinStreamServerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
server:
|
||||
port: 9411
|
||||
|
||||
spring:
|
||||
rabbitmq:
|
||||
host: ${RABBIT_HOST:localhost}
|
||||
datasource:
|
||||
schema: classpath:/mysql.sql
|
||||
url: jdbc:mysql://${MYSQL_HOST:localhost}/test
|
||||
username: root
|
||||
password: root
|
||||
# Switch this on to create the schema on startup:
|
||||
initialize: true
|
||||
continueOnError: true
|
||||
sleuth:
|
||||
enabled: false
|
||||
zipkin:
|
||||
store:
|
||||
type: mysql # default is inMemory
|
||||
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
zipkin:
|
||||
store:
|
||||
type: mem # default is inMemory
|
||||
@@ -0,0 +1,31 @@
|
||||
package example;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import example.ZipkinStreamServerApplication;
|
||||
import io.zipkin.SpanStore;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = ZipkinStreamServerApplication.class)
|
||||
@IntegrationTest({ "server.port=0", "spring.datasource.initialize=true" })
|
||||
@ActiveProfiles("test")
|
||||
public class ZipkinServerApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private SpanStore store;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
int count = this.store.getServiceNames().size();
|
||||
assertEquals(0, count);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
drop table zipkin_spans;
|
||||
drop table zipkin_annotations;
|
||||
drop table zipkin_binary_annotations;
|
||||
drop table zipkin_dependencies;
|
||||
drop table zipkin_dependency_links;
|
||||
Reference in New Issue
Block a user