Skip to content

Commit

Permalink
Resurrects webflux5-sleuth and removes sleuth brave version pin (#113)
Browse files Browse the repository at this point in the history
Sleuth 3.1.11 was released and that fixed flux eureka discovery as well
moved off deprecated functions that made it impossible to update to
Brave 6.0.

Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Feb 10, 2024
1 parent b36cc84 commit 14a408d
Show file tree
Hide file tree
Showing 21 changed files with 534 additions and 99 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
!armeria-kafka/src/main/**
!jersey2-cassandra3/src/main/**
!netty4-grpc/src/main/**
!webmvc5-sleuth/src/main/**
!webflux5-sleuth/src/main/**
!webflux6-micrometer/src/main/**
!webmvc3-jetty/src/main/**
!webmvc4-boot/src/main/**
!webmvc4-jetty/src/main/**
!webmvc5-sleuth/src/main/**
!webmvc25-jetty/src/main/**
!**/pom.xml
!/parent-pom.xml
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/deploy-webflux5-sleuth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# yamllint --format github .github/workflows/deploy.yml
---
name: deploy webflux5-sleuth

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/**"
- "webflux5-sleuth/**"
- ".github/workflows/deploy-webflux5-sleuth.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 }}-webflux5-sleuth-maven-${{ hashFiles('parent-pom.xml', 'webflux5-sleuth/pom.xml') }}
restore-keys: ${{ runner.os }}-webflux5-sleuth-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 webflux5-sleuth
env:
# GH_USER=<user that created GH_TOKEN>
GH_USER: ${{ secrets.GH_USER }}
# GH_TOKEN=<hex token value>
# - 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 webflux5-sleuth &&
build-bin/deploy webflux5-sleuth
37 changes: 37 additions & 0 deletions .github/workflows/test-webflux5-sleuth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# yamllint --format github .github/workflows/test.yml
---
name: test webflux5-sleuth

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/**"
- "webflux5-sleuth/**"
- ".github/workflows/test-webflux5-sleuth.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 }}-webflux5-sleuth-maven-${{ hashFiles('parent-pom.xml', 'webflux5-sleuth/pom.xml') }}
restore-keys: ${{ runner.os }}-webflux5-sleuth-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 webflux5-sleuth
run: |
build-bin/configure_test webflux5-sleuth &&
build-bin/test webflux5-sleuth
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Here are the example projects you can try:
* 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)

* [webflux5-sleuth](webflux5-sleuth) `BRAVE_EXAMPLE=webflux5-sleuth docker-compose up`
* Runtime: Spring 5, Reactor Netty 0.9, Spring Boot 2.3, Spring Cloud Sleuth 2.2, Log4J 2.13, JRE 21
* Trace Instrumentation: [WebFlux Server](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebFilter.java), [WebFlux Client](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientBeanPostProcessor.java), [Reactor Context](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/reactor/ScopePassingSpanSubscriber.java), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Spring Cloud Sleuth](https://github.com/spring-cloud/spring-cloud-sleuth/tree/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig) [Properties](webflux5-sleuth/src/main/resources/application.properties)
* You can also use Eureka discovery like this:
* `BRAVE_EXAMPLE=webflux5-sleuth docker-compose -f docker-compose.yml -f docker-compose-eureka.yml up`

* [webflux6-micrometer](webflux6-micrometer) `BRAVE_EXAMPLE=webflux6-micrometer docker-compose up`
* Runtime: Spring 6, Reactor Netty, Spring Boot 3, Micrometer, Log4J 2, JRE 21
* Trace Configuration: [Spring Boot Actuator](https://github.com/spring-projects/spring-boot/blob/3.2.x/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java)
Expand Down
62 changes: 62 additions & 0 deletions build-bin/docker-compose-eureka.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# permit depends_on/condition: service_healthy
version: '2.4'

# This configures examples so that they use Eureka to discover the Zipkin
# endpoint.
services:
sut:
extends:
file: docker-compose.base.yml
service: sut
depends_on:
get_frontend:
condition: service_started

get_frontend:
extends:
file: docker-compose.base.yml
service: get_frontend
depends_on:
frontend:
condition: service_healthy

frontend:
extends:
file: docker-compose.base.yml
service: frontend
environment:
- EUREKA_SERVICE_URL=http://testuser:testpass@eureka:8761/eureka/v2
depends_on:
backend:
condition: service_healthy

backend:
extends:
file: docker-compose.base.yml
service: backend
environment:
- EUREKA_SERVICE_URL=http://testuser:testpass@eureka:8761/eureka/v2
depends_on:
zipkin:
condition: service_healthy
eureka:
condition: service_healthy

zipkin:
extends:
file: docker-compose.base.yml
service: zipkin
environment:
- EUREKA_SERVICE_URL=http://testuser:testpass@eureka:8761/eureka/v2
- EUREKA_HOSTNAME=zipkin
depends_on:
eureka:
condition: service_healthy

eureka:
image: ghcr.io/openzipkin/zipkin-eureka
container_name: eureka
environment:
- EUREKA_USERNAME=testuser
- EUREKA_PASSWORD=testpass

66 changes: 26 additions & 40 deletions build-bin/docker-compose-kafka.test.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,51 @@
# permit depends_on/condition: service_healthy
version: "2.4"
version: '2.4'

# this duplicates a lot of service definitions because services with depends_on cannot be extended
# This configures examples so that they use Kafka to communicate.
services:
sut:
container_name: sut
image: ghcr.io/openzipkin/alpine:3.19.1
entrypoint: /bin/sh
# Keep the container running until HEALTHCHECK passes
command: "-c \"sleep 5m\""
healthcheck:
# Return 0 when we can read back our trace ID
test: wget -qO- --spider http://zipkin:9411/api/v2/trace/cafebabecafebabe
extends:
file: docker-compose.base.yml
service: sut
depends_on:
get_frontend:
condition: service_started

get_frontend:
container_name: get_frontend
image: ghcr.io/openzipkin/alpine:3.19.1
entrypoint: /bin/sh
# Pass a trace header with a constant trace ID, so that we know what to look for later
command: "-c \"wget -qO- --header 'b3: cafebabecafebabe-cafebabecafebabe-1' http://frontend:8081\""
extends:
file: docker-compose.base.yml
service: get_frontend
depends_on:
frontend:
condition: service_healthy
zipkin:
condition: service_healthy

kafka:
image: ghcr.io/openzipkin/zipkin-kafka:latest
container_name: kafka
# If using docker machine, uncomment the below and set your bootstrap
# server list to 192.168.99.100:19092
# environment:
# - KAFKA_ADVERTISED_HOST_NAME=192.168.99.100
ports:
# Processes on the Docker host can set bootstrap server list to localhost:19092
- 19092:19092

frontend:
container_name: frontend
image: ${DOCKER_IMAGE}
entrypoint: start-frontend
extends:
file: docker-compose.base.yml
service: frontend
environment:
- EUREKA_SERVICE_URL=http://testuser:testpass@kafka:8761/kafka/v2
depends_on:
kafka:
backend:
condition: service_healthy
zipkin:
condition: service_started

backend:
container_name: backend
image: ${DOCKER_IMAGE}
entrypoint: start-backend
extends:
file: docker-compose.base.yml
service: backend
environment:
- EUREKA_SERVICE_URL=http://testuser:testpass@kafka:8761/kafka/v2
depends_on:
zipkin:
condition: service_healthy
kafka:
condition: service_healthy
zipkin:
condition: service_started

zipkin:
extends:
file: docker-compose.test.yml
file: docker-compose.base.yml
service: zipkin

kafka:
image: ghcr.io/openzipkin/zipkin-kafka
container_name: kafka
33 changes: 33 additions & 0 deletions build-bin/docker-compose.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# permit depends_on/condition: service_healthy
version: "2.4"

# This is a base configuration *without depends-on* because docker-compose
# officially doesn't support extending with depends-on even if some tools
# allow it. See https://github.com/docker/compose/issues/7916
services:
sut:
container_name: sut
image: ghcr.io/openzipkin/alpine:3.19.1
entrypoint: /bin/sh
# Keep the container running until HEALTHCHECK passes
command: "-c \"sleep 5m\""
healthcheck:
# Return 0 when we can read back our trace ID
test: wget -qO- --spider http://zipkin:9411/api/v2/trace/cafebabecafebabe
get_frontend:
container_name: get_frontend
image: ghcr.io/openzipkin/alpine:3.19.1
entrypoint: /bin/sh
# Pass a trace header with a constant trace ID, so that we know what to look for later
command: "-c \"wget -qO- --header 'b3: cafebabecafebabe-cafebabecafebabe-1' http://frontend:8081\""
frontend:
container_name: frontend
image: ${DOCKER_IMAGE}
entrypoint: start-frontend
backend:
container_name: backend
image: ${DOCKER_IMAGE}
entrypoint: start-backend
zipkin:
image: ghcr.io/openzipkin/zipkin-slim
container_name: zipkin
50 changes: 23 additions & 27 deletions build-bin/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
# permit depends_on/condition: service_healthy
version: "2.4"
version: '2.4'

services:
sut:
container_name: sut
image: ghcr.io/openzipkin/alpine:3.19.1
entrypoint: /bin/sh
# Keep the container running until HEALTHCHECK passes
command: "-c \"sleep 5m\""
healthcheck:
# Return 0 when we can read back our trace ID
test: wget -qO- --spider http://zipkin:9411/api/v2/trace/cafebabecafebabe
extends:
file: docker-compose.base.yml
service: sut
depends_on:
get_frontend:
condition: service_started

get_frontend:
container_name: get_frontend
image: ghcr.io/openzipkin/alpine:3.19.1
entrypoint: /bin/sh
# Pass a trace header with a constant trace ID, so that we know what to look for later
command: "-c \"wget -qO- --header 'b3: cafebabecafebabe-cafebabecafebabe-1' http://frontend:8081\""
extends:
file: docker-compose.base.yml
service: get_frontend
depends_on:
frontend:
condition: service_healthy
zipkin:
condition: service_healthy

frontend:
container_name: frontend
image: ${DOCKER_IMAGE}
entrypoint: start-frontend
extends:
file: docker-compose.base.yml
service: frontend
depends_on:
backend:
condition: service_healthy
zipkin:
condition: service_started

backend:
container_name: backend
image: ${DOCKER_IMAGE}
entrypoint: start-backend
extends:
file: docker-compose.base.yml
service: backend
depends_on:
zipkin:
condition: service_started
condition: service_healthy

zipkin:
image: ghcr.io/openzipkin/zipkin-slim
container_name: zipkin
extends:
file: docker-compose.base.yml
service: zipkin


5 changes: 4 additions & 1 deletion build-bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ build-bin/docker/docker_build ${docker_image} ${VERSION}
docker_compose_file=build-bin/docker-compose.test.yml

case ${VERSION} in
armeria-kafka* )
armeria|*sleuth* )
docker_compose_file=build-bin/docker-compose-eureka.test.yml
;;
armeria-kafka )
docker_compose_file=build-bin/docker-compose-kafka.test.yml
;;
* )
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-eureka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ services:
service: zipkin
environment:
- EUREKA_SERVICE_URL=http://eureka:8761/eureka/v2
- EUREKA_HOSTNAME=zipkin
# Uncomment to authenticate eureka
# - EUREKA_SERVICE_URL=http://username:password@eureka:8761/eureka/v2
# - EUREKA_HOSTNAME=zipkin
depends_on:
eureka:
condition: service_healthy
Expand Down
Loading

0 comments on commit 14a408d

Please sign in to comment.