From a807b20cccdd7c0fb73d74bcdb54daee29494745 Mon Sep 17 00:00:00 2001 From: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Date: Mon, 8 Jan 2024 12:56:58 +0800 Subject: [PATCH] dropwizard: removes example due to archived smoketurner/dropwizard-zipkin (#99) https://github.com/smoketurner/dropwizard-zipkin is archived, so we can no longer maintain this example, particularly to update to Brave 6.0 Signed-off-by: Adrian Cole --- .dockerignore | 1 - .github/workflows/deploy-dropwizard.yml | 46 ------------- .github/workflows/test-dropwizard.yml | 37 ---------- README.md | 5 -- docker/bin/install-example | 1 - docker/bin/post-install-example-dropwizard | 12 ---- dropwizard/README.md | 6 -- dropwizard/pom.xml | 40 ----------- .../src/main/java/brave/example/Backend.java | 42 ------------ .../brave/example/BackendConfiguration.java | 14 ---- .../brave/example/ExampleApplication.java | 67 ------------------- .../src/main/java/brave/example/Frontend.java | 51 -------------- .../brave/example/FrontendConfiguration.java | 37 ---------- dropwizard/src/main/resources/example.yml | 22 ------ 14 files changed, 381 deletions(-) delete mode 100644 .github/workflows/deploy-dropwizard.yml delete mode 100644 .github/workflows/test-dropwizard.yml delete mode 100755 docker/bin/post-install-example-dropwizard delete mode 100644 dropwizard/README.md delete mode 100644 dropwizard/pom.xml delete mode 100644 dropwizard/src/main/java/brave/example/Backend.java delete mode 100644 dropwizard/src/main/java/brave/example/BackendConfiguration.java delete mode 100644 dropwizard/src/main/java/brave/example/ExampleApplication.java delete mode 100644 dropwizard/src/main/java/brave/example/Frontend.java delete mode 100644 dropwizard/src/main/java/brave/example/FrontendConfiguration.java delete mode 100644 dropwizard/src/main/resources/example.yml diff --git a/.dockerignore b/.dockerignore index 4eb09a4..9eacc4b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,7 +11,6 @@ # Allow on-demand "mvn package". !armeria/src/main/** !armeria-kafka/src/main/** -!dropwizard/src/main/** !jersey2-cassandra3/src/main/** !netty4-grpc/src/main/** !ratpack/src/main/** diff --git a/.github/workflows/deploy-dropwizard.yml b/.github/workflows/deploy-dropwizard.yml deleted file mode 100644 index 6784aba..0000000 --- a/.github/workflows/deploy-dropwizard.yml +++ /dev/null @@ -1,46 +0,0 @@ -# yamllint --format github .github/workflows/deploy.yml ---- -name: deploy dropwizard - -on: - # We deploy non-tagged pushes to master relevant for this project. We can't opt out of - # documentation-only commits because GH actions does not permit paths and paths-ignore. - push: - tags: '' - branches: master - paths: - - "build-bin/**" - - "docker/**" - - "dropwizard/**" - - ".github/workflows/deploy-dropwizard.yaml" - - "parent-pom.xml" - -jobs: - deploy: - runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: ./m2repository # Shared with the Docker build context via .dockerignore - key: ${{ runner.os }}-dropwizard-maven-${{ hashFiles('parent-pom.xml', 'dropwizard/pom.xml') }} - restore-keys: ${{ runner.os }}-dropwizard-maven- - # Don't attempt to cache Docker. Sensitive information can be stolen - # via forks, and login session ends up in ~/.docker. This is ok because - # we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner. - - name: Deploy dropwizard - env: - # GH_USER= - GH_USER: ${{ secrets.GH_USER }} - # GH_TOKEN= - # - pushes Docker images to ghcr.io - # - create via https://github.com/settings/tokens - # - needs repo:status, public_repo, write:packages, delete:packages - GH_TOKEN: ${{ secrets.GH_TOKEN }} - run: | - build-bin/configure_deploy dropwizard && - build-bin/deploy dropwizard diff --git a/.github/workflows/test-dropwizard.yml b/.github/workflows/test-dropwizard.yml deleted file mode 100644 index 20c70fb..0000000 --- a/.github/workflows/test-dropwizard.yml +++ /dev/null @@ -1,37 +0,0 @@ -# yamllint --format github .github/workflows/test.yml ---- -name: test dropwizard - -on: - # We deploy non-tagged pushes to master relevant for this project. We can't opt out of - # documentation-only commits because GH actions does not permit paths and paths-ignore. - pull_request: - branches: master - paths: - - "build-bin/**" - - "docker/**" - - "dropwizard/**" - - ".github/workflows/test-dropwizard.yaml" - - "parent-pom.xml" - -jobs: - test: - runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: ./m2repository # Shared with the Docker build context via .dockerignore - key: ${{ runner.os }}-dropwizard-maven-${{ hashFiles('parent-pom.xml', 'dropwizard/pom.xml') }} - restore-keys: ${{ runner.os }}-dropwizard-maven- - # Don't attempt to cache Docker. Sensitive information can be stolen - # via forks, and login session ends up in ~/.docker. This is ok because - # we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner. - - name: Test dropwizard - run: | - build-bin/configure_test dropwizard && - build-bin/test dropwizard diff --git a/README.md b/README.md index 0607a4f..016bfdb 100644 --- a/README.md +++ b/README.md @@ -46,11 +46,6 @@ Here are the example projects you can try: * Trace Instrumentation: [Armeria](https://armeria.dev/), [Kafka Clients](https://github.com/openzipkin/brave/tree/master/instrumentation/kafka-clients), [Kafka Streams](https://github.com/openzipkin/brave/tree/master/instrumentation/kafka-streams), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j) * Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](armeria/src/main/java/brave/example/HttpTracingFactory.java) -* [dropwizard](dropwizard) `BRAVE_EXAMPLE=dropwizard docker-compose up` - * Runtime: JaxRS 2, Jersey 2.31, Apache HttpClient 4.5, Jetty 9.4, SLF4J 1.7, JRE 21 - * Trace Instrumentation: [Jersey Server](https://github.com/openzipkin/brave/tree/master/instrumentation/jersey-server), [Apache HttpClient](https://github.com/openzipkin/brave/tree/master/instrumentation/httpclient), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j) - * Trace Configuration: [Dropwizard Zipkin](https://github.com/smoketurner/dropwizard-zipkin) [Java](dropwizard/src/main/java/brave/example/ExampleApplication.java) [Yaml](dropwizard/src/main/resources/server.yml) - * [jersey2-cassandra3](jersey2-cassandra3) `BRAVE_EXAMPLE=jersey2-cassandra3 docker-compose up` * Runtime: JaxRS 2, Jersey 2.32, DataStax Java Driver 3.0, Apache Cassandra 3.11, SLF4J 1.7, JRE 8 * Trace Instrumentation: [Jersey Server](https://github.com/openzipkin/brave/tree/master/instrumentation/jersey-server), [DataStax Java Driver](https://github.com/openzipkin/brave-cassandra/tree/master/cassandra-driver), [Apache Cassandra](https://github.com/openzipkin/brave-cassandra/tree/master/cassandra), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j) diff --git a/docker/bin/install-example b/docker/bin/install-example index 7cd41ec..c510ff9 100755 --- a/docker/bin/install-example +++ b/docker/bin/install-example @@ -67,7 +67,6 @@ cp -p /code/build-bin/docker/docker-healthcheck . # Make any platform-specific revisions case ${version} in *-jetty ) /code/docker/bin/post-install-example-jetty;; - dropwizard ) /code/docker/bin/post-install-example-dropwizard;; # Ratpack system properties must be prefixed with "ratpack." ratpack ) sed -i 's/-D/-Dratpack./g' start-frontend start-backend;; *-cassandra3 ) /code/docker/bin/post-install-example-cassandra;; diff --git a/docker/bin/post-install-example-dropwizard b/docker/bin/post-install-example-dropwizard deleted file mode 100755 index 79be788..0000000 --- a/docker/bin/post-install-example-dropwizard +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -eux - -# DropWizard crashes if properties are unknown -sed -i 's/brave.localServiceName/zipkin.serviceName/g' start-frontend start-backend - -# dropwizard-zipkin doesn't understand these yet -sed -i '/brave.supportsJoin/d' start-frontend start-backend -sed -i '/brave.traceId128Bit/d' start-frontend start-backend - -# DropWizard system properties must be prefixed with "dw." -sed -i 's/-D/-Ddw./g' start-frontend start-backend diff --git a/dropwizard/README.md b/dropwizard/README.md deleted file mode 100644 index fb6883d..0000000 --- a/dropwizard/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Tracing Example: Dropwizard - -Instead of servlet, this uses [Dropwizard](https://www.dropwizard.io) to serve HTTP -requests. Both services run as a normal Java application. - -* brave.example.FrontendResource and BackendResource : JaxRS controllers diff --git a/dropwizard/pom.xml b/dropwizard/pom.xml deleted file mode 100644 index 7c8a527..0000000 --- a/dropwizard/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - io.zipkin.brave.example - brave-example-parent - 1.0-SNAPSHOT - ../parent-pom.xml - - - brave-example-dropwizard - jar - - brave-example-dropwizard - Tracing Example: Dropwizard/ Java 21 - - - 21 - 8 - - - 2.0.16-1 - - - - - - com.smoketurner.dropwizard - zipkin-core - ${dropwizard-zipkin.version} - - - com.smoketurner.dropwizard - zipkin-client - ${dropwizard-zipkin.version} - - - diff --git a/dropwizard/src/main/java/brave/example/Backend.java b/dropwizard/src/main/java/brave/example/Backend.java deleted file mode 100644 index da3a975..0000000 --- a/dropwizard/src/main/java/brave/example/Backend.java +++ /dev/null @@ -1,42 +0,0 @@ -package brave.example; - -import com.smoketurner.dropwizard.zipkin.ZipkinFactory; -import io.dropwizard.setup.Environment; -import java.util.Date; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; - -/** Example conventions include a self-contained main class. */ -public class Backend extends ExampleApplication { - - @Path("/") - public static class Resource { - @GET - @Path("/api") - public String printDate(@HeaderParam("user_name") String username) { - if (username != null) { - return new Date().toString() + " " + username; - } - return new Date().toString(); - } - } - - Backend() { - super("backend", 9000); - } - - @Override public void run(BackendConfiguration configuration, Environment environment) { - super.run(configuration, environment); - environment.jersey().register(new Resource()); - } - - @Override ZipkinFactory zipkinFactory(BackendConfiguration configuration) { - return configuration.getZipkin(); - } - - public static void main(String[] args) throws Exception { - new Backend().run(); - } -} - diff --git a/dropwizard/src/main/java/brave/example/BackendConfiguration.java b/dropwizard/src/main/java/brave/example/BackendConfiguration.java deleted file mode 100644 index 43e4426..0000000 --- a/dropwizard/src/main/java/brave/example/BackendConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package brave.example; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.smoketurner.dropwizard.zipkin.HttpZipkinFactory; -import com.smoketurner.dropwizard.zipkin.ZipkinFactory; -import io.dropwizard.Configuration; - -public class BackendConfiguration extends Configuration { - final ZipkinFactory zipkin = new HttpZipkinFactory(); - - @JsonProperty public ZipkinFactory getZipkin() { - return zipkin; - } -} diff --git a/dropwizard/src/main/java/brave/example/ExampleApplication.java b/dropwizard/src/main/java/brave/example/ExampleApplication.java deleted file mode 100644 index 76a442e..0000000 --- a/dropwizard/src/main/java/brave/example/ExampleApplication.java +++ /dev/null @@ -1,67 +0,0 @@ -package brave.example; - -import com.smoketurner.dropwizard.zipkin.ZipkinBundle; -import com.smoketurner.dropwizard.zipkin.ZipkinFactory; -import io.dropwizard.Application; -import io.dropwizard.Configuration; -import io.dropwizard.configuration.ResourceConfigurationSourceProvider; -import io.dropwizard.setup.Bootstrap; -import io.dropwizard.setup.Environment; -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -/** Helper to bootstrap {@link ZipkinBundle} and reduce replication in example setup. */ -abstract class ExampleApplication extends Application { - /** Fake /health endpoint that allows us to ensure our HEALTHCHECK doesn't start traces. */ - @Path("/") - public static class HealthCheck { - @GET - @Path("/health") - public String health() { - return "ok"; - } - } - - final String name; - ZipkinBundle zipkinBundle; - - ExampleApplication(String name, int port) { - this.name = name; - System.setProperty("dw.server.applicationConnectors[0].port", String.valueOf(port)); - - // Copy properties to zipkin config until we learn how to do the following in example.yaml: - // - // zipkin: - // serviceName: ${environment.name} - // servicePort: ${dw.server.applicationConnectors[0].port} - System.setProperty("dw.zipkin.serviceName", name); - System.setProperty("dw.zipkin.servicePort", String.valueOf(port)); - } - - @Override public final String getName() { - return name; - } - - @Override public void run(C configuration, Environment environment) { - // Our example is single port per app. Also, it is easiest when all health URLs are the same - // HTTP path (/health). As these aren't configurable, add our own /health directly - environment.jersey().register(new HealthCheck()); - } - - /** Centralized config for both applications go into one yaml file. */ - void run() throws Exception { - run("server", "example.yml"); - } - - abstract ZipkinFactory zipkinFactory(C configuration); - - @Override public final void initialize(Bootstrap bootstrap) { - bootstrap.setConfigurationSourceProvider(new ResourceConfigurationSourceProvider()); - zipkinBundle = new ZipkinBundle(getName()) { - @Override public ZipkinFactory getZipkinFactory(C configuration) { - return zipkinFactory(configuration); - } - }; - bootstrap.addBundle(zipkinBundle); - } -} diff --git a/dropwizard/src/main/java/brave/example/Frontend.java b/dropwizard/src/main/java/brave/example/Frontend.java deleted file mode 100644 index ae195db..0000000 --- a/dropwizard/src/main/java/brave/example/Frontend.java +++ /dev/null @@ -1,51 +0,0 @@ -package brave.example; - -import com.smoketurner.dropwizard.zipkin.ZipkinFactory; -import com.smoketurner.dropwizard.zipkin.client.ZipkinClientBuilder; -import io.dropwizard.setup.Environment; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.client.Client; -import javax.ws.rs.core.Response; - -/** Example conventions include a self-contained main class. */ -public class Frontend extends ExampleApplication { - @Path("/") - public static class Resource { - final Client client; - final String backendEndpoint; - - Resource(Client client, String backendEndpoint) { - this.client = client; - this.backendEndpoint = backendEndpoint; - } - - @GET - @Path("/") public Response callBackend() { - return client.target(backendEndpoint).request().get(); - } - } - - Frontend() { - super("frontend", 8081); - } - - @Override public void run(FrontendConfiguration configuration, Environment environment) { - super.run(configuration, environment); - - Client client = new ZipkinClientBuilder(environment, zipkinBundle.getHttpTracing().get()) - .build(configuration.getBackend()); - - Resource resource = new Resource(client, configuration.getBackend().getEndpoint()); - - environment.jersey().register(resource); - } - - @Override ZipkinFactory zipkinFactory(FrontendConfiguration configuration) { - return configuration.getZipkin(); - } - - public static void main(String[] args) throws Exception { - new Frontend().run(); - } -} diff --git a/dropwizard/src/main/java/brave/example/FrontendConfiguration.java b/dropwizard/src/main/java/brave/example/FrontendConfiguration.java deleted file mode 100644 index 056a1cf..0000000 --- a/dropwizard/src/main/java/brave/example/FrontendConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package brave.example; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.smoketurner.dropwizard.zipkin.HttpZipkinFactory; -import com.smoketurner.dropwizard.zipkin.ZipkinFactory; -import com.smoketurner.dropwizard.zipkin.client.ZipkinClientConfiguration; -import io.dropwizard.Configuration; -import javax.validation.constraints.NotNull; - -public class FrontendConfiguration extends Configuration { - static class BackendConfiguration extends ZipkinClientConfiguration { - @NotNull String endpoint = "http://127.0.0.1:9000/api"; - - BackendConfiguration() { - setServiceName("backend"); - } - - @JsonProperty public String getEndpoint() { - return endpoint; - } - - @JsonProperty public void setEndpoint(String endpoint) { - this.endpoint = endpoint; - } - } - - final ZipkinFactory zipkin = new HttpZipkinFactory(); - final BackendConfiguration backend = new BackendConfiguration(); - - @JsonProperty public ZipkinFactory getZipkin() { - return zipkin; - } - - @JsonProperty public BackendConfiguration getBackend() { - return backend; - } -} \ No newline at end of file diff --git a/dropwizard/src/main/resources/example.yml b/dropwizard/src/main/resources/example.yml deleted file mode 100644 index 5e444f2..0000000 --- a/dropwizard/src/main/resources/example.yml +++ /dev/null @@ -1,22 +0,0 @@ -# We have to set a default in yaml in order to override with system properties -server: - applicationConnectors: - - type: http - port: 8080 - adminConnectors: [] - -zipkin: - collector: http - baseUrl: http://127.0.0.1:9411/ - serviceName: ${environment.name} - servicePort: ${dw.server.applicationConnectors[0].port} - -logging: - level: INFO - appenders: - - type: console - timeZone: UTC - # Adds trace IDs into the log format - logFormat: "%-5p [%d{ISO8601,UTC}] [%X{userName}] [%X{traceId}/%X{spanId}] %c: %m%n%rEx" - target: stdout -