Skip to content

Commit

Permalink
fixes grpc example and bumps all deps including docker images (#124)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored May 14, 2024
1 parent 2541c60 commit 3164cc8
Show file tree
Hide file tree
Showing 19 changed files with 201 additions and 279 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This is an example app where two Java services collaborate on a request.

Notably, these services send data to [Zipkin](https://zipkin.io/), a
distributed tracing system. Zipkin allows you to see the how long the operation
distributed tracing system. Zipkin allows you to see how long the operation
took, as well how much time was spent in each service.

Here's an example of what it looks like:
Expand All @@ -15,7 +15,7 @@ to send tracing data to a third service [Zipkin](https://zipkin.io/). [Brave](ht
performs this function.

# Running the example
To setup the demo, you need to start Frontend, Backend and Zipkin. You can do
To set up the demo, you need to start Frontend, Backend and Zipkin. You can do
this using Java commands or Docker.

Once the services start, open http://localhost:8081/
Expand Down Expand Up @@ -54,7 +54,7 @@ Here are the example projects you can try:
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [XML](jersey2-cassandra3/src/main/webapp/WEB-INF/tracing.xml)

* [netty4-grpc](netty4-grpc) `BRAVE_EXAMPLE=netty4-grpc docker-compose up`
* Runtime: Netty 4.1, Google gRPC 1.34 , SLF4J 1.7, JRE 21
* Runtime: Netty 4.1, Google gRPC 1.63, SLF4J 1.7, JRE 21
* Trace Instrumentation: [Netty Codec HTTP](https://github.com/openzipkin/brave/tree/master/instrumentation/netty-codec-http), [Google gRPC](https://github.com/openzipkin/brave/tree/master/instrumentation/grpc), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](netty4-grpc/src/main/java/brave/example/TracingConfiguration.java)

Expand Down
4 changes: 2 additions & 2 deletions armeria-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<jre.version>21</jre.version>
<maven.compiler.release>8</maven.compiler.release>

<armeria.version>1.27.2</armeria.version>
<kafka.version>3.6.1</kafka.version>
<armeria.version>1.28.4</armeria.version>
<kafka.version>3.7.0</kafka.version>
</properties>

<dependencies>
Expand Down
45 changes: 1 addition & 44 deletions armeria/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,13 @@
<jre.version>21</jre.version>
<maven.compiler.release>8</maven.compiler.release>

<armeria.version>1.27.2</armeria.version>
<armeria.version>1.28.4</armeria.version>
</properties>

<dependencies>
<dependency>
<groupId>com.linecorp.armeria</groupId>
<artifactId>armeria</artifactId>
<exclusions>
<!-- temporary until netty includes https://github.com/netty/netty/pull/13724 -->
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- temporary until netty-4.1.108.Final -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.63.Final</version>
<classifier>linux-x86_64</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.63.Final</version>
<classifier>linux-aarch_64</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.63.Final</version>
<classifier>osx-x86_64</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.63.Final</version>
<classifier>osx-aarch_64</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.63.Final</version>
<classifier>windows-x86_64</classifier>
<scope>runtime</scope>
</dependency>

<!-- Instruments the underlying Armeria requests -->
Expand Down
6 changes: 3 additions & 3 deletions build-bin/docker/docker_args
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ if [ -n "${DOCKER_TARGET}" ]; then
fi

# When non-empty, becomes the layer that builds the maven projects.
# e.g. ghcr.io/openzipkin/java:11.0.22_p7
# e.g. ghcr.io/openzipkin/java:11.0.23_p9
#
# This must include maven and a full JDK.
if [ -n "${DOCKER_BUILD_IMAGE}" ]; then
docker_args="${docker_args} --build-arg docker_build_image=${DOCKER_BUILD_IMAGE}"
fi

# When non-empty, becomes the base layer including tag appropriate for the image being built.
# e.g. ghcr.io/openzipkin/java:21.0.2_p13-jre
# e.g. ghcr.io/openzipkin/java:21.0.3_p9-jre
#
# This is not required to be a base (FROM scratch) image like ghcr.io/openzipkin/alpine:3.12.3
# See https://docs.docker.com/glossary/#parent-image
Expand All @@ -59,7 +59,7 @@ if [ -n "${ALPINE_VERSION}" ]; then
docker_args="${docker_args} --build-arg alpine_version=${ALPINE_VERSION}"
fi

# When non-empty, becomes the build-arg java_version. e.g. "21.0.2_p13"
# When non-empty, becomes the build-arg java_version. e.g. "21.0.3_p9"
# Used to align base layers from https://github.com/orgs/openzipkin/packages/container/package/java
if [ -n "${JAVA_VERSION}" ]; then
docker_args="${docker_args} --build-arg java_version=${JAVA_VERSION}"
Expand Down
20 changes: 10 additions & 10 deletions build-bin/docker_args
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ else
exit 1
fi

JAVA_VERSION=${JAVA_VERSION:-21.0.2_p13}
JAVA_VERSION=${JAVA_VERSION:-21.0.3_p9}
# DOCKER_ARCHS to eventually push to the registry
DOCKER_ARCHS="amd64 arm64"

case "${JRE_VERSION}" in
6 )
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.22_p7
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.23_p9
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:1.6.0-119
# single arch image
DOCKER_ARCHS=amd64
;;
7 )
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.22_p7
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.23_p9
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:1.7.0_285
# single arch image
DOCKER_ARCHS=amd64
;;
8 )
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.22_p7
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.23_p9
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:8.392.08-jre
;;
11 )
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.22_p7
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:11.0.22_p7-jre
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:11.0.23_p9
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:11.0.23_p9-jre
;;
17 )
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:21.0.2_p13
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:17.0.10_p7-jre
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:21.0.3_p9
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:17.0.11_p9-jre
;;
21 )
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:21.0.2_p13
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:21.0.2_p13-jre
DOCKER_BUILD_IMAGE=ghcr.io/openzipkin/java:21.0.3_p9
DOCKER_PARENT_IMAGE=ghcr.io/openzipkin/java:21.0.3_p9-jre
;;
* )
echo "Invalid JRE_VERSION: ${JRE_VERSION}"
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# non-root users and such as they are not intended to run in production anyway.

# The image binaries this example builds are installed over
ARG docker_parent_image=ghcr.io/openzipkin/java:21.0.2_p13
ARG docker_parent_image=ghcr.io/openzipkin/java:21.0.3_p9
## Use JDK 11 to build projects, as that can still compile Java 6
ARG docker_build_image=ghcr.io/openzipkin/java:11.0.22_p7
ARG docker_build_image=ghcr.io/openzipkin/java:11.0.23_p9

# We copy files from the context into a scratch container first to avoid a problem where docker and
# docker-compose don't share layer hashes https://github.com/docker/compose/issues/883 normally.
Expand Down
8 changes: 4 additions & 4 deletions jersey2-cassandra3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<maven.compiler.release>8</maven.compiler.release>

<!-- Use a container that doesn't use Netty. -->
<jersey.version>2.41</jersey.version>
<spring.version>5.3.31</spring.version>
<jersey.version>2.43</jersey.version>
<spring.version>5.3.34</spring.version>

<cassandra.version>4.1.3</cassandra.version>
<cassandra-driver-core.version>3.11.2</cassandra-driver-core.version>
<cassandra.version>4.1.4</cassandra.version>
<cassandra-driver-core.version>3.11.5</cassandra-driver-core.version>

<!-- https://github.com/openzipkin/brave-cassandra -->
<brave-cassandra.version>0.13.1</brave-cassandra.version>
Expand Down
4 changes: 2 additions & 2 deletions netty4-grpc/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Tracing Example: Netty 4.1/Google gRPC 1.34/JRE 21
## Tracing Example: Netty 4.1/Google gRPC 1.63/JRE 21

Instead of servlet, the frontend is a Netty HTTP handler. The backend is Google gRPC 1.31.
Both services run as a normal Java application.
Expand All @@ -7,7 +7,7 @@ Both services run as a normal Java application.
* [brave.example.Backend](src/main/java/brave/example/Backend.java) - Google gRPC server
* [brave.example.TracingConfiguration](src/main/java/brave/example/TracingConfiguration.java) - Configures trace instrumentation

Here's an example screen shot:
Here's an example screenshot:
![screen shot](https://user-images.githubusercontent.com/64215/102683005-a2986500-4208-11eb-8258-92cc02f9310b.png)

This example also shows Brave's `BaggagePropagation`. If you make a request to the frontend with
Expand Down
13 changes: 9 additions & 4 deletions netty4-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<packaging>jar</packaging>

<name>brave-example-netty4-grpc</name>
<description>Tracing Example: Netty 4.1/Google gRPC 1.34/JRE 21</description>
<description>Tracing Example: Netty 4.1/Google gRPC 1.63/JRE 21</description>

<properties>
<jre.version>21</jre.version>
<maven.compiler.release>8</maven.compiler.release>

<grpc.version>1.34.1</grpc.version>
<protobuf.version>3.12.0</protobuf.version>
<grpc.version>1.63.0</grpc.version>
<protobuf.version>3.25.1</protobuf.version>

<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
Expand All @@ -33,6 +33,11 @@
<artifactId>grpc-services</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
Expand Down Expand Up @@ -63,7 +68,7 @@
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-context-slf4j</artifactId>
<artifactId>brave-context-log4j12</artifactId>
</dependency>

<!-- The below are needed to report traces to http://127.0.0.1:9411/api/v2/spans -->
Expand Down
2 changes: 1 addition & 1 deletion netty4-grpc/src/main/java/brave/example/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void main(String[] args) throws Exception {

/**
* Google's gRPC impl disallows reading headers inside a server handler. This copies a header into
* the context so we can see if it was propagated or not.
* the context, so we can see if it was propagated or not.
*/
static final class CopyHeaderToGrpcContext implements ServerInterceptor {
final Key<String> contextKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import brave.baggage.BaggagePropagation;
import brave.baggage.BaggagePropagationConfig;
import brave.baggage.CorrelationScopeConfig;
import brave.context.slf4j.MDCScopeDecorator;
import brave.context.log4j12.MDCScopeDecorator;
import brave.grpc.GrpcTracing;
import brave.http.HttpTracing;
import brave.netty.http.NettyHttpTracing;
Expand Down
Loading

0 comments on commit 3164cc8

Please sign in to comment.