Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions zipkin-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,4 +525,6 @@ To build and run the server from the currently checked out source, enter the fol
$ ./mvnw -Dlicense.skip=true -DskipTests --also-make -pl zipkin-server clean install
# Run the server
$ java -jar ./zipkin-server/target/zipkin-server-*exec.jar
# or Run the slim server
$ java -jar ./zipkin-server/target/zipkin-server-*slim.jar
```
132 changes: 131 additions & 1 deletion zipkin-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@
<artifactId>jul-to-slf4j</artifactId>
</dependency>

<!-- the "exec" jar will exclude this -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>provided</scope>
</dependency>

<!-- Static content for the Classic UI -->
<dependency>
<groupId>io.zipkin.java</groupId>
Expand Down Expand Up @@ -249,7 +256,7 @@
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-context-log4j2</artifactId>
<artifactId>brave-context-slf4j</artifactId>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -491,6 +498,129 @@
</goals>
<configuration>
<classifier>exec</classifier>
<excludes>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
</excludes>
</configuration>
</execution>

<!-- Make a jar less than half the size, which only supports armeria-native features -->
<execution>
<id>slim</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>slim</classifier>
<!-- https://github.com/spring-projects/spring-boot/issues/3426 transitive exclude doesn't work -->
<excludeGroupIds>
io.zipkin.java,com.google.auto.value,com.google.guava,io.dropwizard.metrics,com.datastax.cassandra,com.github.jnr,org.ow2.asm,org.jooq,javax.xml.bind,org.mariadb.jdbc,com.zaxxer,org.apache.activemq,org.apache.geronimo.specs,org.fusesource.hawtbuf,org.apache.kafka,com.github.luben,org.lz4,org.xerial.snappy,com.rabbitmq,jakarta.annotation,org.apache.thrift,org.apache.logging.log4j
</excludeGroupIds>
<excludes>
<!-- Actuator -->
<dependency>
<groupId>${armeria.groupId}</groupId>
<artifactId>armeria-spring-boot-actuator-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<!-- Brave -->
<dependency>
<groupId>${armeria.groupId}</groupId>
<artifactId>armeria-brave</artifactId>
</dependency>

<!-- Log4J 2 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

<!-- Unnecessary netty deps -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-haproxy</artifactId>
</dependency>

<!-- Unnecessary micrometer deps -->
<!-- TODO: https://github.com/micrometer-metrics/micrometer/issues/1599 -->
<!-- <dependency>-->
<!-- &lt;!&ndash; only used by TimeWindowPercentileHistogram &ndash;&gt;-->
<!-- <groupId>org.hdrhistogram</groupId>-->
<!-- <artifactId>HdrHistogram</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- &lt;!&ndash; we don't use pause detector &ndash;&gt;-->
<!-- <groupId>org.latencyutils</groupId>-->
<!-- <artifactId>LatencyUtils</artifactId>-->
<!-- </dependency>-->

<!-- storage and collectors which have 3rd party deps -->
<dependency>
<groupId>${project.groupId}.zipkin2</groupId>
<artifactId>zipkin-storage-cassandra-v1</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}.zipkin2</groupId>
<artifactId>zipkin-storage-cassandra</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.brave.cassandra</groupId>
<artifactId>brave-instrumentation-cassandra-driver</artifactId>
</dependency>

<!-- MySQL backend -->
<dependency>
<groupId>${project.groupId}.zipkin2</groupId>
<artifactId>zipkin-storage-mysql-v1</artifactId>
</dependency>

<!-- ActiveMQ Collector -->
<dependency>
<groupId>${project.groupId}.zipkin2</groupId>
<artifactId>zipkin-collector-activemq</artifactId>
</dependency>

<!-- Kafka Collector -->
<dependency>
<groupId>${project.groupId}.zipkin2</groupId>
<artifactId>zipkin-collector-kafka</artifactId>
</dependency>

<!-- RabbitMQ Collector -->
<dependency>
<groupId>${project.groupId}.zipkin2</groupId>
<artifactId>zipkin-collector-rabbitmq</artifactId>
</dependency>

<!-- Scribe Collector -->
<dependency>
<groupId>${project.groupId}.zipkin2</groupId>
<artifactId>zipkin-collector-rabbitmq</artifactId>
</dependency>
<exclude>
<groupId>${armeria.groupId}</groupId>
<artifactId>armeria-thrift</artifactId>
</exclude>
</excludes>
</configuration>
</execution>
</executions>
Expand Down
5 changes: 5 additions & 0 deletions zipkin-server/src/it/slimjar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# slimjar
This includes tests that use the slim jar produced by the zipkin-server build.

It intentionally doesn't depend on any zipkin pom, to ensure the only
thing in the classpath is the slim jar.
91 changes: 91 additions & 0 deletions zipkin-server/src/it/slimjar/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2015-2019 The OpenZipkin 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">
<modelVersion>4.0.0</modelVersion>
<groupId>@project.groupId@</groupId>
<version>@project.version@</version>
<artifactId>slimjar</artifactId>
<name>slimjar</name>

<dependencies>
<dependency>
<groupId>@project.groupId@.zipkin2</groupId>
<artifactId>zipkin</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>@okhttp.version@</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>@project.groupId@</groupId>
<artifactId>zipkin-server</artifactId>
<version>@project.version@</version>
<classifier>slim</classifier>
<exclusions>
<!-- TODO: should the slim jar declare dependencies it bundles? -->
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>@assertj.version@</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>@maven-compiler-plugin.version@</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>@maven-failsafe-plugin.version@</version>
<configuration>
<failIfNoTests>true</failIfNoTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2015-2019 The OpenZipkin 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 zipkin.slimjar;

import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.Rule;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;

public class AdminEndpointsTest {
@Rule public ExecJarRule zipkin = new ExecJarRule();

OkHttpClient client = new OkHttpClient();

/** Tests admin endpoints work eventhough actuator is not a strict dependency. */
@Test public void adminEndpoints() throws Exception {
try {
// Documented as supported in our zipkin-server/README.md
assertThat(get("/health").isSuccessful()).isTrue();
assertThat(get("/info").isSuccessful()).isTrue();
assertThat(get("/metrics").isSuccessful()).isTrue();
assertThat(get("/prometheus").isSuccessful()).isTrue();

// Check endpoints we formerly redirected to. Note we never redirected to /actuator/metrics
assertThat(get("/actuator/health").isSuccessful()).isTrue();
assertThat(get("/actuator/info").isSuccessful()).isTrue();
assertThat(get("/actuator/prometheus").isSuccessful()).isTrue();
} catch (RuntimeException | IOException e) {
fail(String.format("unexpected error!%s%n%s", e.getMessage(), zipkin.consoleOutput()));
}
}

private Response get(String path) throws IOException {
return client.newCall(new Request.Builder()
.url("http://localhost:" + zipkin.port() + path)
.build()).execute();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2015-2019 The OpenZipkin 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 zipkin.slimjar;

import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.Rule;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;

public class DoesntCrashWhenElasticsearchIsDownTest {
@Rule public ExecJarRule zipkin = new ExecJarRule()
.putEnvironment("STORAGE_TYPE", "elasticsearch")
.putEnvironment("ES_HOSTS", "127.0.0.1:9999");

OkHttpClient client = new OkHttpClient();

@Test public void startsButReturns500QueryingStorage() throws IOException {
try {
Response services = get("/api/v2/services");
assertThat(services.code())
.withFailMessage(services.body().string())
.isEqualTo(500);
} catch (RuntimeException | IOException e) {
fail(String.format("unexpected error!%s%n%s", e.getMessage(), zipkin.consoleOutput()));
}
}

@Test public void startsButReturnsFailedHealthCheck() throws IOException {
try {
assertThat(get("/health").code()).isEqualTo(503);
} catch (RuntimeException | IOException e) {
fail(String.format("unexpected error!%s%n%s", e.getMessage(), zipkin.consoleOutput()));
}
}

private Response get(String path) throws IOException {
return client.newCall(new Request.Builder()
.url("http://localhost:" + zipkin.port() + path)
.build()).execute();
}
}
Loading